6 ms·
I think you're wrong (although I could just be being silly..). As a mailing list comment points out, the effect of applying the for(c...) part to an n is:
by andrew1 16y ago
I think you're wrong (although I could just be being silly..).
As a mailing list comment points out, the effect of applying the for(c...) part to an n is:
fc(n) = n * (2 ^ n) * (2 ^ (n * (2 ^ n))
So the first iteration of the d variable sets n = fc(n), then the second sets it to fc(fc(n)), which is the answer.
fc(2) = 2 * (2 ^ 2) * (2 ^ (2 * (2 ^ 2)) = 2048
so we want to find
fc(2048) mod (10 ^ 10).
Consider a simpler question, what are the last two digits, i.e.
fc(2048) mod 100
We need one fact here to help, the periodicity of 2 ^ k mod 100 is 20, i.e.
2 ^ (20q + r) = 2 ^ r mod 100
So:
fc(2048) mod 100
= 2048 * (2 ^ 2048) * (2 ^ (2048 * (2 ^ 2048)) =
= 48 * (2 ^ 8) * (2 ^ ( 8 * (2 ^ 8)) [we can reduce all exponents mod 20, same in all below lines]
= 48 * 256 * (2 ^ ( 8 * 256 ) )
= 48 * 56 * (2 ^ 2048)
= 48 * 56 * (2^8)
= 28 * 56 * 56
= 150528
= 28.
So I think that the last two digits should be 28. I don't know what the answer is for the last 10 digits though.
- jules 16y ago> As a mailing list comment points out, the effect of applying > the for(c...) part to an n is: > fc(n) = n * (2 ^ n) * (2 ^ (n * (2 ^ n)) This is not true. You need to apply the following formula n times, not 2 times (in this case n=2048). n <- n*2^n