It helps to have:
N = n0 + 10n1 + 100n2 + ...
M = m0 + 10m1 + 100m2 + ...
where the undercase ms and ns are integers between 0 and 9. Then, the last two digits of U = NM are given by
u0 = n0m0 mod 10 and
u1 = n0m1 + n1m0 + floor(n0m0/10) mod 10
It is good practice to look into the circumstances under which m0 and m1 can be chosen so that u1 = u0. This implies:
m1n0 = n0m0 - m0n1 - floor(n0m0/10) mod 10
Now, if n0 is relatively prime to 10 (n0 = 1,3, or 7) then we have the fortuitous circumstance that, by varying m1, we can reach all possible values mod 10, so we are also completely free in how we pick m0..
|
Posted by FrankM
on 2015-02-14 13:15:51 |