DEV Community

Discussion on: How do you calculate 3^3^3^3? (What algo / struct?)

Collapse
patarapolw profile image
Pacharapol Withayasakpunt Author • Edited on

I tried, but not to the end, with exponentiation by squaring.

I stopped at

(3.2485963e+6846169)^3 == (3.4283664e+20538506)
Enter fullscreen mode Exit fullscreen mode

And I cached the file storing 6846170 + 20538507 digits, and it takes 27 MB

[0] % du -sh cache/k_cubed/* | sort -h | tail -n 1
27M     cache/k_cubed/32485...48187 (3.248e+6846169)
Enter fullscreen mode Exit fullscreen mode

BTW, the expected result is

12577936...00739387 (1.2577936e+3638334640024)
Enter fullscreen mode Exit fullscreen mode

I may get some of the first digits wrong, though.