File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes General Computing and the fly likes BigInteger and project Euler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "BigInteger and project Euler" Watch "BigInteger and project Euler" New topic

BigInteger and project Euler

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

i just solved #48
The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317.

Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.

it was the easiest one so far(almost trivial) although fewer people have solved it than earlier problems which were harder for me. i credit the BigInteger class for this. i am thinking it must be harder to deal with huge numbers in other languages. any comments?

Visit my download page
Matthew Brown

Joined: Apr 06, 2010
Posts: 4543

Yeah, that one is pretty trivial in any language that has an unlimited integer type. If you want more of a challenge, try doing it without BigInteger - or just move on to the next one .

Have a look at problem 97. That's another one that is trivial in theory with BigInteger, but you may find it will take ages that way - to get it down to a reasonable time you need to implement your own method to take advantage of the fact that it only wants the last 10 digits.
I agree. Here's the link:
subject: BigInteger and project Euler
It's not a secret anymore!