Project Euler/16: Difference between revisions
From charlesreid1
No edit summary |
No edit summary |
||
| Line 11: | Line 11: | ||
user 0m1.166s | user 0m1.166s | ||
sys 0m0.090s | sys 0m0.090s | ||
</pre> | |||
{{ProjectEulerFlag}} | |||
[[Category:Big Integer]] | |||
Revision as of 02:12, 5 July 2017
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.
$ time javac BigNum.java && java BigNum real 0m0.630s user 0m1.166s sys 0m0.090s