What are the last 12 digits of 1 2 3 4 5 6 7 8 9 9 8 7 6 5 4 3 2 1 ?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Did you encounter any difficulty in term of significant figures? What was the total number of significant figures of the type of real number that you were using?
I suppose this is very certainly not the intended solution:
1 2 |
|
Which just means we can just re-implement exponentiation by squaring :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Exponentiation by squaring is a fast way to compute such high powers.
MATHEMATICA ONE-LINER : PowerMod[123456789,987654321,10^12]
Simple standard approach.
123456789 = 3 × 3 × 3607 × 3803
123456789 for String_9;
Grouped as 3 × 3607, and 3 × 3803 respectively for String_12;
With 18 S.F. calculations, 132974933589 is derived from _ 974933589, 801066457221 and 475687966609 for 381057674154132974933589.
123456789 based for 974933589;
10821 based for 801066457221 and
11409 based for 475687966609.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
It took few hours to complete evaluations by computer with faster routines.
Answer: 1 3 2 9 7 4 9 3 3 5 8 9
This a solution in python 3.4 that not use recursive function.
1 2 3 4 5 6 7 8 9 |
|
Problem Loading...
Note Loading...
Set Loading...
This is an excellent example of where "Exponentiation by squaring" can be used. The key here is that:
x n = x ( x 2 ) 2 n − 1 , if n is odd
and
x n = ( x 2 ) 2 n , if n is even