Adopted new convention from template
This commit is contained in:
parent
67120f400e
commit
f829cce7fb
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python
|
||||||
"""
|
"""
|
||||||
Created on 15 Sep 2018
|
Created on 15 Sep 2018
|
||||||
|
|
||||||
@ -10,26 +10,27 @@ https://projecteuler.net/problem=20
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from math import factorial
|
from math import factorial
|
||||||
|
|
||||||
from utils import timeit
|
from utils import timeit
|
||||||
|
|
||||||
|
|
||||||
@timeit("Problem 20")
|
@timeit("Problem 20")
|
||||||
def compute():
|
def compute():
|
||||||
"""
|
"""
|
||||||
n! means n × (n − 1) × ... × 3 × 2 × 1
|
n! means n x (n - 1) x ... x 3 x 2 x 1
|
||||||
|
|
||||||
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
|
For example, 10! = 10 x 9 x ... x 3 x 2 x 1 = 3628800,
|
||||||
and the sum of the digits in the number 10! is:
|
and the sum of the digits in the number 10! is:
|
||||||
3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
|
3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
|
||||||
|
|
||||||
Find the sum of the digits in the number 100!
|
Find the sum of the digits in the number 100!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
fact = factorial(100)
|
fact = factorial(100)
|
||||||
sum_digits = sum(int(digit) for digit in str(fact))
|
sum_digits = sum(int(digit) for digit in str(fact))
|
||||||
|
|
||||||
return sum_digits
|
return sum_digits
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
print(f"Result for Problem 20 is {compute()}")
|
||||||
print(f"Result for Problem 20: {compute()}")
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user