suppose i have a variable b = t*4+s
if i happen to know b, is it possible to get t and s, using div and mod? how?
t=?
s=?
suppose i have a variable b = t*4+s
if i happen to know b, is it possible to get t and s, using div and mod? how?
t=?
s=?
b = (t * 4) + s
t = (b - s) / 4
s = b - (t * 4)
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
I got this:
s = b/(t*4)
t = (b-s)/4
substitute t in the first equation:
s = b/((b-s)/4)*4) = b/(b-s)
manipulate equation and get:
s^2 - sb + b = 0
or do it for the t equation and get:
4t^2 - bt + 4b = 0
now solve for s or t, then substitute it back into the equation.
I think I did it right???
There's probably a better way though.
obviously
b = t*4+s
cannot have unique soln for any given b
so given b you can assume values for t
say from 1 to 100 and then find the corresponding value of s or vice versa
ie 10 = 1*4 +6
also = 2*4 +2
= 3*4 +(-2)
and so on
jv