Formula for Game of Numbers

Mar 2012
564
29
I am trying to find a formula for this game.

You will be given two numbers. For example: 20 and 640. You have to test those two numbers on a 3rd number N.

The testing is like this. Let us assume N = 4, then
20/4 = 5
640/4 = 160

since I have no remainder, when N = 4, the answer is 5 and 160

if N = 7
20/7 = 2.857
640/7 = 91.429

when I get a decimal answer, I can choose numbers when I multiply them and sum them I get 20
4x3 + 2x3 + 1x2 = 20, for those numbers I care about the left numbers for example 4x3, I care about 4
then I have 4, 2, and 1
then I look at this number (91.429), reduce it to 91. I am allowed to take 91 or 91 + 1 or 91 - 1, in other words 90, 91, 92
92x4 + 90x2 + 92x1 = 640

then the answer when N = 7 is (4, 92), (2, 90) and (1,92)

I am flexible to answer the same N=7 in a different way if I want
for example
4x2 + 3x4 = 20
91x4 + 92x3 = 640

when N = 7, the answer also could be (4,91) and (3,92)

when N = 12
20/12 = 1.6667
640/12 = 53.333

8x2 + 4x1 = 20
53x8 + 54x4 = 640

the answer when N = 12 is (8,53) and (4,54)

when N = 13
20/13 = 1.538
640/13 = 49.231

I tried to solve this but I could not. Therefore, is there a general formula that can help me to find the answer easily?
 
Jan 2009
439
125
I think you are misleading yourself through your coordinate notation when dealing with two numbers instead of one number - considering two starting numbers is a red herring.

I would word the problem in the following way. Given two numbers, a and N, and j = floor(a/N), does there exist a linear combination of integer values, l, m, n such that
l (j-1) + mj + n(j+1) = a?

The answer appears to be yes, since the integers l, m, n appear to be relatively free variables. (I can stand to be corrected on this)

l (j-1) + mj + n(j+1) = a ?
(l + m + n)j + (n-l) = a ?
(l + m + n)j = a - (n-l) ?

As long as n, l are chosen such that a - (n-l) is divisible by integer j, we have a class of integer values to choose from for l, m, n

Consider the example, a = 20, N = 7. j = floor(20/7) = 2
We want
(l + m + n) * 2 = 20 - (n - l)

We can let n - l = 0 so that 20 - (n - l) = 20, a multiple of 2. This implies n = l
This means
(l + m + n) * 2 = 20
(l + m + n) = 10
m + 2n = 10, since we let n = l

We can let n = 1, and thus m = 8

Thus we can satisfy the equation with (l,m,n) = (1,8,1). ie. 1*1 + 8*2 + 1*3 = 20. (There appears to be an infinite amount of integer solutions)
 
Last edited:
Mar 2012
564
29
thanks a lot, MacstersUndead. that was so clear.