Project Euler Problem 020

Statement

n! means n × (n − 1) × … × 3 × 2 × 1

Find the sum of the digits in the number 100!

Solution

On a language like Python that can handle large numbers
easily.

if __name__ == '__main__':
    num = 1
    for i in range(1, 100+1):
        num *= i
    result = 0
    while num > 0:
        result += num % 10
        num //= 10
    print("The result is:", result)

The Python file is available for download here.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License