Project Euler – Problem 20
2012-05-05 08:30
357 查看
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!
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!
#!/usr/bin/env python # coding: utf-8 def jc(n): if n == 1: return 1 else: return n * jc(n-1) def SumOfJc(n): s = 0 for i in str(jc(n)): s += int(i) return s if __name__ == "__main__": print(SumOfJc(100))
相关文章推荐
- [Project Euler] Problem 20
- [Project Euler] Problem 20
- Project Euler:Problem 20 Factorial digit sum
- Project Euler:Problem 11 Largest product in a grid
- Project Euler:Problem 53 Combinatoric selections
- Project Euler - Problem 13
- Project Euler:Problem 70 Totient permutation
- Project Euler:Problem 76 Counting summations
- Project Euler:Problem 78 Coin partitions
- [Project Euler] Problem 55
- Problem 15 - Starting in the top left corner in a 20 by 20 grid, how many routes are there to the bottom right corner?
- 【Project Euler】【Problem 1】Multiples of 3 and 5
- 【Project Euler】【Problem 10】Summation of primes
- Project Euler__problem 8
- [Project Euler]加入欧拉 Problem 11
- [Project Euler] Problem 4
- [Project Euler] Problem 12
- [Project Euler] Problem 23
- Project Euler:Problem 12 Highly divisible triangular number
- Project Euler:Problem 22 Names scores