From charlesreid1

Revision as of 02:11, 5 July 2017 by Admin (talk | contribs) (Created page with "Project Euler problem 16: https://projecteuler.net/problem=16 Problem 16 asks to find the sum of the digits of <math>2^1000</math>. This is obviously much larger than the ca...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Project Euler problem 16: https://projecteuler.net/problem=16

Problem 16 asks to find the sum of the digits of $ 2^1000 $.

This is obviously much larger than the capacity of Java's int, $ 2^32 $, or long, $ 2^64 $. However, Java's math library has a big integer type built in that allows for arbitrary precision algebra. Solving this problem is as easy as learning how to call it. The number is not as large as it looks - it won't overwhelm a computer to actually compute it. Java computes it in less than a second.

charles at maya in ~/cs/euler/016
$ time javac BigNum.java && java BigNum

real	0m0.630s
user	0m1.166s
sys	0m0.090s