David Doblas Jiménez 7c8165d9c2 Clean-up
2021-09-20 17:53:15 +02:00

35 lines
746 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
Created on 15 Sep 2018
@author: David Doblas Jiménez
@email: daviddoji@pm.me
Solution for problem 20 of Project Euler
https://projecteuler.net/problem=20
"""
from math import factorial
from utils import timeit
@timeit("Problem 20")
def compute():
"""
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!
"""
fact = factorial(100)
sum_digits = sum(int(digit) for digit in str(fact))
return sum_digits
if __name__ == "__main__":
print(f"Result for Problem 20: {compute()}")