Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

BigInteger and project Euler  RSS feed

 
Randall Twede
Ranch Hand
Posts: 4583
6
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!