134 points · by nigamanth · 3y ago · 91 comments
Learn a handful of logs base 10 (not much more work than the cube digit laws). Maybe you know 2,3,5 and e.
19,683 is equal to 20,000
log 20,000 is log 2 + log 10 + log 10 + log 10 + log 10
That's 0.30 + 1 + 1 + 1 + 1 which is 4.30
Divide by 3 (equivalent to taking cube root). That's 1.43
Recall that log e is 0.43. So 1.43 is log (e * 10). Hopefully you remember e = 2.71, so the number you're looking for is 27.1. If you remember that you rounded up to start, you can round back down and guess that it's more like 27.0.
You can simplify this a little further by dividing out thousands and multiplying by 10s at the end, so you only need to find the cube root of 20 using the same process.
So the natural log of the cube root is (presumably) 3 ln(3), making the cube root itself 27.
Alternatively, the digit sum of 19,683 is 27, so the cube is a multiple of 9. Given that it's a perfect cube, 19,683 must be a multiple of 3^3 = 27. Dividing by that gives 729, or 9^3, so the cube root is 3 * 9=27.
Lastly, it's possible to dredge up that e^3 is about 20, so (27.1828...)^3 is about 20,000, and it's plausible that 27 is the cube root we're after.
My mental landmarks are ln(2), ln(e), and ln(10), roughly 0.7, 1.0, and 2.3 respectively.
Me attempting to even read your method: *idiotic blank stare*
In base 10, this works for every odd power but for no even power. (if you're given that a square ends in anything but 0 or 5, there are always two different possibilities for the last digit of the square root)
Here are the powers (less than 100) for which this works in different bases (up to 25). Now I'm quite confused: what is the pattern here and what is the number-theoretic explanation for it?
(Edit: It looks like the bases for which no power, except the trivial case of 1, has this property are exactly those bases that are divisible by a perfect square -- but I wouldn't have expected that and still don't know how to account for it.)
2 [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, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
3 [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]
4 [1]
5 [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]
6 [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]
7 [1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37, 41, 43, 47, 49, 53, 55, 59, 61, 65, 67, 71, 73, 77, 79, 83, 85, 89, 91, 95, 97]
8 [1]
9 [1]
10 [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]
11 [1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, 47, 49, 51, 53, 57, 59, 61, 63, 67, 69, 71, 73, 77, 79, 81, 83, 87, 89, 91, 93, 97, 99]
12 [1]
13 [1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37, 41, 43, 47, 49, 53, 55, 59, 61, 65, 67, 71, 73, 77, 79, 83, 85, 89, 91, 95, 97]
14 [1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37, 41, 43, 47, 49, 53, 55, 59, 61, 65, 67, 71, 73, 77, 79, 83, 85, 89, 91, 95, 97]
15 [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]
16 [1]
17 [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]
18 [1]
19 [1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37, 41, 43, 47, 49, 53, 55, 59, 61, 65, 67, 71, 73, 77, 79, 83, 85, 89, 91, 95, 97]
20 [1]
21 [1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37, 41, 43, 47, 49, 53, 55, 59, 61, 65, 67, 71, 73, 77, 79, 83, 85, 89, 91, 95, 97]
22 [1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, 47, 49, 51, 53, 57, 59, 61, 63, 67, 69, 71, 73, 77, 79, 81, 83, 87, 89, 91, 93, 97, 99]
23 [1, 3, 5, 7, 9, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97]
24 [1]
25 [1]We're working with numbers modulo 10, i.e. Z/10Z = {0,1,2,3,4,5,6,7,9}.
Its multiplicative subgroup consists of all the elements with a multiplicative inverse, which are {1,3,7,9}. Note that 1*1 = 1, 3*7 = 21 = 1 (mod 10), and 9*9 = 81 = 1 (mod 10). Its size is phi(10) = phi(2*5) = phi(2) * phi(5) = 1 * 4 = 4.
When computing powers, the exponent can be reduced modulo the size of the multiplicative subgroup: n^e mod m = n ^ {e mod phi(m) } mod m.
In this case of m=10, powers that are 1 or 3 mod 4 are bijections, others are not.
An easy way to look at this is that the numbers are equivalent to {0, 1, -1} mod 3, and so the powers are {0^n, 1^n, and (-1)^n}, which is only a bijection for odd n (otherwise, 1^n = (-1)^n). Indeed, you can generalize this to the statement that even powers cannot be bijections for any base N > 2, as 1 != -1 mod N.
I believe you'll find that the powers that are bijections are those relatively prime with phi(N) (as a consequence of the Chinese remainder theorem [0]), outside of the special case GP asked about:
With (nontrivial) perfect square factors, there are nontrivial roots for n^2 = 0 mod N (namely: solutions other than 0 mod N).
For instance, in octal, consider 4 * 4 = 16 (0o20 which ends in zero). Any greater powers of 4 in octal will also end in zero.
[0] This is in fact critical to the decryptability of RSA, which requires that m^(e*d) = m mod N, or equivalently that for a given e, m^e is invertible for all choices of m, i.e. f(m) = m^e mod N is a bijection: https://crypto.stackexchange.com/questions/12255
0 has no multiplicative inverse. 1 and 2 = -1 are their own inverse.
- it ends in 3, so the cube root must be a multiple of 3
- 30*3 is intuitively going to be 27,000, and 20*3 will be 8,000
- that leaves only 21, 24 and 27 to choose from, and given the exponential shape for 8k - 27k, I went with the largest
Not a "solution", as I couldn't be certain without confirming, but interesting how close a logical deduction could get.
Intuition is incredibly underrated - I have learned to trust the first damned fool thing that pops into my head, before any conscious thought has had time to get moving and therefore interfere. It’s usually correct, regardless of context - and when it goes wrong, it’s because I accidentally allowed myself to think and reason.
It’s in the same category as “walking away from a problem”, in my view - you can’t solve it, you go grab a coffee, and while you’re looking for the sugar the answer is just suddenly there in your head, because you stopped running the CPU-intensive conscious process, and let the background workers catch up.
Conscious thought is great for producing outputs for other humans to then work with. Unconscious through this great for… everything else. We do incredibly complex things all the time - catching a ball, walking upright, looking in the direction of that sudden sound - but typically run all of the gnarly logic in an abstraction layer within a virtual machine, rather than on the hardware that was designed to run it natively.
No end of trouble at school where I wouldn’t just not show my working, but couldn’t - but the real world fortunately doesn’t particularly care about the means, just the ends.
I doubt the average person can rely on their untrained intuition for large square roots.
One of my favourite tricks is just knowing, to +- 1 minute, what time it is. I don’t set an alarm, I just plan to wake at whatever time. If someone asks the time I give it without checking. It actually works better when I’m asleep, as I will wake +- 10 seconds from the intended time, which shows just how much consciousness interferes.
Honestly, it’s laziness - thinking takes far too much effort and is much too slow, and 80% right in 1% of the execution time is a “good enough” optimisation.
The "cube root" part contains the implicit information that we have a product ending in 3, of three identical factors.
I guess the missing assumption is that given the context of solving the cube root in ones head, it would more likely be a trick that only works with integers, and as such the correct answer might be expected to be one.
I don't get it. 7 cubed is 343. The article explains better what numbers might have cubes ending in 3.
> - it ends in 3, so the cube root must be a multiple of 3
And also believe this > that leaves only 21, 24 and 27 to choose from,
without noticing that 21^3 ends in 1 and 24^3 is even?
It's like you're doing math in a while different axiom system.
But not notice that this >
I was doing math in an axiom system made for the problem.
Possibly not a good idea in math, but in programming it's kind of what we do. (I don't guarantee it's bug-free or works with different input...)
Like, by inspection (sum of digits) this number has 3 as a factor. That means 3 has to also be a prime factor of its cube root which means 27 has to be a factor of the cube.
So we can divide out 27, leaving us with the smaller problem of finding 3(cbrt(729)), which you might recognize as being 3*9, or spot that you can repeat the trick to give you 9(cbrt(27))…
Or you might notice that if 19683 has to contain 27 as a factor, that doesn’t leave a lot of room for any other cubed prime factors to exist in the number, and do a trial multiplication to confirm that 27 just is the cube root.
Basically comes down to, if you have a comfortable relationship with how numbers relate to their factors, you can develop a number of instincts for how to recognize shapes within them.
First, note that, since the digit sum of 19683 is a multiple of 9, 19683 itself is a multiple of 9. Second, since 19683 is odd, its cube root will be odd as well. Therefore, the cube root of 19683 will be an odd multiple of 3.
To find 19683¹ᐟ³, will take the base 10 log of 19683, divide by 3, and raise the result to the 10th power, approximating where convenient.
To this end, it will be helpful to have approximate values for lg 2 and lg 5. Since 10³ ≈ 1024 = 2¹⁰ = 10^(lg[2]·10), we have 3 ≈ lg[2]·10. Solving, we find that lg 2 ≈ 0.3. Next, since 10 = 2·5, we have lg[10] = 1 = lg[2·5] = lg 2 + lg 5, so lg 5 = 1 − lg 2 ≈ 0.7.
Using those approximations, we calculate:
lg[19683¹ᐟ³] ≈ lg[20000¹ᐟ³] = lg[2·10000]/3 = (lg 2 + lg 10000)/3 ≈ (0.3 + 4)/3 ≈ 1.43.
Since 25 = 5·5, we have lg 25 = lg 5 + lg 5 ≈ 1.4. This means we're looking for an odd multiple of 3 near 25. The closest number that fits the bill is 27. Cubing, we find that 27·27·27 = 19683, so we are done.
2. Find the cube root of 653,503
It should be 658,503…
The job is to find x.
Assuming 19683 has an integer cube root, I would guess the last digit x to be 7, because that gives us the 3: 7 * 7 = 49, and 9 * 7 = 63.
Thus, the answer is probably 27. Cubing 27 mentally to validate the answer is the harder thing for me. :)
The cube of 3 ends with 7 and cube of 7 end with 3
The cube of 2 ends with 8 and cube of 8 end with 2
Cube-buddies
The solution should obviously be somewhere between 20 and 30. Since I knew 25^2 = 625 already, I multiplied by 25 to arrive at 25^3 = 15625.
From there I used the approximation (1 + x)^n = 1 + nx which works if x << 1.
19683 = 15625*(1 + x) = 25^3*(1 + x) with x ~= 4000/15625 ~= 0.25. This stretches the condition ("x << 1") for the approximation a lot but so be it.
(1 + 1/4)^1/3 ~= 1 + 1/12.
25*(1 + 1/12) ~= 27
Good enough ;)
If I had needed cube roots equally often, would I have been just as good at mentally intuition roughly what number it has to be?
Or are humans somehow wired to deal with linearities more intuitively than powers? Or is it our mathematical notation (Arabic numbers are linear, as opposed to some log scale) that creates that impression?
I don't think there has been an explanation proposed for why it's easier to do linear math in our heads, I have to imagine this is just the effect of school.
What is 17463/3 ?
To 2 sig figs, it's trivial because you only have to divide a digit by 3 and then interpolate the fractional part.
(As far as doing the calc, I thought it has to end in 7 becaus3 it’s the only one with a cub3 residue of 3 mod 10, which is what they say in post. Then 20 and 30 cubed are 8000 and 27000 respectively and assuming we’re restricting to Z 27 is the only possible answer)
Also, I have an additional question.
Obviously this trick relies on the fact that "the last digit of the cube of all numbers from 0 to 9 is distinct".
Is this fact just coincidence, or is it bound to happen?
But he only likes to talk about acting and scrabble.
1^3 = 1
2^3 = 8
3^3 = 27
4^3 = 64
5^3 = 125
6^3 = 216
7^3 = 343
8^3 = 512
9^3 = 729
As you can see, for decimal system, last digit of cubes is unique for all digits. As last digit of cube depends on last digit of cube root only (same for squares and so on), it is bound to be true for all numbers
I was asking if this (cubes of number 0-9, the one you list, all have unique last digit in 0-9) a coincidence or not.
(I know a number's cube's last digit is only affected by its own last digit.)
My intuition is to guess that `gcd(n,m) = 1` is at least a sufficient condition (correct math term? In german it's "hinreichende Bedingung"). Maybe it's the sole necessary condition. But I did only think about this for 5 to 10s and did not spend too much time on looking for a counter example, let alone a proof strategy (my number theory is a bit rusty -- ah, but on second thought, if the theory is correct, then I bet the Chinese remainder theorem is involved).
For the n-the square root just group the digits by n starting from the ones. That will tell you how many digits you're dealing with. Simplish math will give you the first digit off of the last grouping (simple since you only have to ^n the numbers from 1-10)
Simple counting and a bit of math and I have the order of mag and first digit.
2_
At this point I can either think of a decent trick to iterate the second digit (quick Taylor? [1]), or just guesstimate a linear fit and call it a 5.
25 is within 10%.
[1] instead of Taylor I would do Pascal's triangle on the cube with the next term to calculate (30-x)^3 (I use 30 - x and not 20+x since I want x as small as possible and I know the answer is closer to 30 than 20.
Pascal's triangle:
1(30)^3 + 3(30)^2x + 330x^2 + 1x^3
Drop the higher two terms.
3^3 + 33^2x = 19
19-27 = 27x
X = 8/27 = 1/3 (- 1/27)
30-3.3 = 26.66
I use the sign of the next term of pascal's triangle to see if Ive under or over estimated
3
3*(-0.3)^2 -> positiveSo my x is too large
So my answer is an underestimate.
(Cube root of 19000) greater than but close to 26.6
If the abstract understanding of root properties is being asked, the question will be presented using variables. The cube root function is effectively equivalent to the square root function execpt the range includes negative values, when looking at it graphically.
I’m a fan of some of the math problems on Project Euler. This isn’t high school math, of course, but many problems are carefully designed such that blindly using a computer to solve them just doesn’t work. This forces you to think about the problem more deeply and use that to come up with tricks that reduce the search space. This is very much along the same lines as this blog post, but generalized to bigger harder problems.
And FWIW, stuff like this - a deep interest in math and how there are often many different ways to solve a problem, and the study of digits and numbers and polynomials and roots and efficient ways to manipulate them - is quite core to my job and all the people I work with. I do mostly software at a company that makes hardware and software, and number-theoretic thinking and fun & “impractical” tricks put into practice are literally everywhere.
I guess I’m saying I think that there actually is a lot of practical value in this kind of play, for the engaged audience, and once someone goes beyond basic high school & college math, in addition to the benefits of increased motivation that you mentioned. I wouldn’t be so quick to write it off as pointless, and only teach to the test. Maybe if we had more of this in high school, we’d have a better math education system. I’d agree we need to teach all kids how to use calculators, but I also think we need to teach kids how to think deeply about numbers, and have the skills to build tricks and do mental estimation, and send more of them into science and tech jobs with exploration skills emphasized and prioritized over calculator skills.
Edit: Ah wait cube root. That is the square root I just tried.
26.something is what my mental calculations gave me. I thought it was going to be 27. Turns out it is. I made an error somewhere which is why you gotta do this on paper.
As for method I kind of brie brute forced it. started with 100 cubed which is hundred thousand then 20 cubed which is 8000 then 30 cubed which is 3 cubed times 10 cubed which is 27k. 25 cubed which I don't remember but was less then, then I knew it could not be 26 because the number is not even. I'd deal with fractions later. so I tried 27 cubed. 27 cubed is 3^3^3=2733^5=8133^4=24333^3= 72927=72920+7297 72920=72902=14400+180=14580 7297=4900+140+63=5103 Add them and 19683 comes out
Now try that in your head and it's a good recipe for frying one's brain.
My heuristic is to find a nearby square (here, 140^2 = 19600) and divide the discrepancy (83) by double the root of the nearby square (280). This is the number to adjust by. [^0]
[^0] The Maclaurin series expansion of (A^2 + x)^(1/2) starts A + x/(2A), which is where this comes from.
83/280 is close to 84/280, which is 12/40 or 0.3. If I was trying to show off [^1], I might adjust that -- 1/28 is a quarter of a seventh, about 0.0357, so I can take 0.004 off of my adjustment to get 0.296 or 0.297.
[^1] I mean, show off more.
(The actual answer is 140.29611 -- the "0.3" adjustment is right to one part in 36,000; "0.296" is right to one part in 1.2 million.)
(though unsure how many of your traffic primarly reads article on mobile, so it might not even be an impactful issue)
Suppose you are trying to find cbrt(x), and you know the answer is a 2-digit integer.
===============
Hensel: first you have to remove any powers of 5 and 2. You know the cube root is even if the number is even, and a multiple of 5 if the number is a multiple of 5 (ends in a 0 or 5). So factor those out first. It now ends in 1,3,7 or 9.
Find the cube root w of x mod 10, and t = 1/3x mod 10, by trial and error. Eg, x=19683 ends in 3, so w ends in 7 (since 7^3 ends in 3); t = 1/3x ends in 9 since 39x ends in 1.
Calculate the tens digit of the error term e = x - w^3, which is always a multiple of 10. In this case it's ...683 - 343 === 40, and apply the adjustment w ==> w + wte. You only need to calculate the 10s digit of wte. In this case, it's the 10's digit of 7*9*40 = 63*40 is 20.
That's all, the answer is 27.
===============
CRT: Find the answer mod 10 and mod 11. As before, the answer here mod 10 is 7.
For mod 11, you can reduce it to a 2-digit problem by applying %99 first, i.e. shifting each digit over by 2 until it's a 10s or 1s digit, and adding. We have 19683 mod 11 = (1 + 96 + 83) mod 11 = 180 mod 11 = 81 mod 11 = 4.
Find the cube root mod 11 by exhaustion, or by memorization, or by taking the 7th power of the input (Fermat's theorem). In this case, it's 5, because 5^3 mod 11 = 125 mod 11 =(1+25) mod 11 = 4.
Solve using the CRT: if a number is y mod 10 and z mod 11, then it's y + 10(y-z mod 11). In this case, it's 7 + 10(7-5 mod 11) = 27.
================
Euler: the answer is always the same as the last 2 digits of x^7. Calculate eg x^2, x^3, x^6, x^7 with four multiplications. You only need the last two digits.
Probably this is the easiest approach by hand.
================
If you want to solve on a computer, then Hensel mod 2^n (continuing the pattern appropriately for more bits) is probably the fastest bet.
You might be good at Mathematics, this is like a standard trick the average student can do. There are lots of other approaches but the easiest one to do mentally is this.
(Any direction, solving for the rate, or for the time, or the principal needed)
^2 and ^3 are quite easy but when it comes to ^7/^9 there's no easy way to calculate mentally.
It's over 10 since 10^3=1000.
So this narrows it to more than 10 and less than 100.
log-wise 30 is about midway between 10 and 100. 900 x 30 is is 27000 so it's less than 30.
20? 400 x 20 = 8000 so bigger than that.
Then it gets annoying to compute the cubes so close enough to say more than 20 and less than 30.
What's 30 cubed? 27 and three zeros, so not far away.
What's 27 cubed? Oh, that's it.
One of the things that you should learn is that the problems that humans set for each other usually involve integers or well known numbers.
First we observe x is between 20^3=8e3 and 30^3=27e3.
Then note that the least significant (singles) digit of x^3 is solely determined by the singles digit of x [only holds in the integers].
Luckily we had cached that the pattern for cubes is 123456789 -> 187456329
Finally x^3 = 19,683 ends in 3 therefore x = 27 we are done.
------ It turns out there is a unique mapping for the first digit of x^n, following one of four patterns:
n mod 4 = 1 123456789 -> 123456789
n mod 4 = 2 -> 149656941
n mod 4 = 3 -> 187456329
n mod 4 = 0 -> 161656161
So this trick would not always be as useful, where the mapping is not surjective for squares, fourth powers -- all the even powers. I imagine there is a nice visual geometric explanation why those mappings take their symmetric pattern.You may ask yourself, is there also a rule for the larger place digits of x^3, x^n? Yes, we naturally observe that the 10s digit of x^n is similarly wholly determined by the 10s and 1s digits of x. So now we want n maps on [0,9]x[0,9] to [0,9].
The python snippet may help to explore this: where the row 3, 25th digit shows that when x ends in 25, x cubed has 10s digit 2
>>> print(*zip(range(50), [''.join([str(x**i).zfill(2)[-2:-1] for x in range(100)]) for i in range(50)]), sep='\n')
(0, '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000')
(1, '0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999')
(2, '0000123468024692582604827272840628529642086432100000001234680246925826048272728406285296420864321000')
(3, '0002621412032947913506462278580963075571028082329405076719170824429630014127735304680250760785873799')
(4, '0018529096043612327208547274580272321634069092581000185290960436123272085472745802723216340690925810')
(5, '0034227064053927756900342270640539277569003422706405392775690034227064053927756900342270640539277569')
(6, '0062925444068032162802087278020826123086044452926000629254440680321628020872780208261230860444529260')
(7, '0028823456070107573304842270100167479397084062167405238739510206025238098927751506624298920345671179')
...
(19, '0086429478094787353708082276960769671755062002581405814799730442823032030327719102646212500125075319')
(20, '0070727070007072707000707270700070727070007072707000707270700070727070007072707000707270700070727070')
(21, '0050025000011167116102722272220333873383049442944405550755050616621666077727772708388238880999479949')
(22, '0000123468024692582604827272840628529642086432100000001234680246925826048272728406285296420864321000')
(23, '0002621412032947913506462278580963075571028082329405076719170824429630014127735304680250760785873799')
(24, '0018529096043612327208547274580272321634069092581000185290960436123272085472745802723216340690925810')
...
(35, '0060227434056527793900602274340565277939006022743405652779390060227434056527793900602274340565277939')
(36, '0032925054061432187802967276920878123416045052923000329250540614321878029672769208781234160450529230')
(37, '0076823046079307576304102274800137479107085462182405718735410298025268091527798506324296020359671329')
(38, '0048321482080252902406667276660420925208028412384000483214820802529024066672766604209252080284123840')
(39, '0086429478094787353708082276960769671755062002581405814799730442823032030327719102646212500125075319')
(40, '0070727070007072707000707270700070727070007072707000707270700070727070007072707000707270700070727070')
(41, '0050025000011167116102722272220333873383049442944405550755050616621666077727772708388238880999479949')
(42, '0000123468024692582604827272840628529642086432100000001234680246925826048272728406285296420864321000')
(43, '0002621412032947913506462278580963075571028082329405076719170824429630014127735304680250760785873799')
...
-----Apologies for the wall of text but the output is included here to show the periodicity is 20 in the 10s digit for powers of n.
What do you think the periodicity in the 100s digit is?
Okay let's use our cache to just lookup the least two digits of say, 41679296 ^ 35 (without doing any real compute):
1s digit
35 mod 4 = 3
187456329 index 6 -> 6
10s digit
(35, '0060227434056527793900602274340565277939006022743405652779390060227434056527793900602274340565277939')
index ------96 -> 7
The last two digits of 41679296 ^ 35 = 497981393104388234083687472206165994017494365065741791800324926291638211001469403054062791593737655590988883756006534609416313532750908441977019034732014717649617778735038244085515193249673259731575280032440237649262981884959117005449913087392615145373869733708824576 are indeed 76, cool