4 ms·
If you know that the number is a perfect cube, you could also try Hensel's lemma or CRT, or Euler, all of which are aaaaalmost doable in your head for 2 digits,
by less_less 4y ago
If you know that the number is a perfect cube, you could also try Hensel's lemma or CRT, or Euler, all of which are aaaaalmost doable in your head for 2 digits, but maybe not quite.
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.
- nigamanth 4y ago> all of which are aaaaalmost doable in your head for 2 digits, but maybe not quite. 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.