Project Euler - Problem 20


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/usr/bin/python
  2.  
  3. # Project Euler - Problem 20
  4. import math
  5.  
  6. print "\nProject Euler - Problem 20"
  7. print " What is the sum of the digits of 100!?\n"
  8.  
  9. num = math.factorial(100)
  10. sum = 0
  11. str = str(num)
  12.  
  13. for x in str:
  14. sum += int(x)
  15.  
  16. print sum

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.