• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

BigInteger and project Euler

 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic