aspose file tools
The moose likes Programming Diversions and the fly likes Project Euler - Problem 20 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Other » Programming Diversions
Reply Bookmark "Project Euler - Problem 20" Watch "Project Euler - Problem 20" New topic
Author

Project Euler - Problem 20

Aashu Aggarwal
Greenhorn

Joined: Aug 01, 2012
Posts: 4
Problem statement -

n! means n (n 1) ... 3 2 1

For example, 10! = 10 9 ... 3 2 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.

Find the sum of the digits in the number 100!


I am trying to solve it but 100! is big even for long. I thought i can try to break the factorial in parts and then solve it but still in end i have to multiply all the results which overshoot the long.

Looking for some guidance.

Thanks,
Aashu
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10043
    
    6

Check the java API for something that might let you work with a Big Integer...


Never ascribe to malice that which can be adequately explained by stupidity.
Aashu Aggarwal
Greenhorn

Joined: Aug 01, 2012
Posts: 4
fred rosenberger wrote:Check the java API for something that might let you work with a Big Integer...


Thanks Fred. That worked perfectly :-)
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Project Euler - Problem 20
 
Similar Threads
project Euler problem 16
Sum of Digits
why are the answers different?
problem with while loop
Scanner class help