Позначка: factorial

  • Find the sum of the digits in the number 100! (Python)

    Find the sum of the digits in the number 100! (Python)

    Python code to demonstrate a method to compute the factorial digists sum, i.e. 100 factorial (100!).

    This test exercise I’ve recieved when I was looking for a Trainee Python Developer position.

    n = 100
    fact = 1
      
    for i in range(1, n+1): 
        fact = fact * i
    
    # Convert number to string
    text_fact = str(fact)
    
    # Initialize empty list for every letter of factorial string 
    summ = []
    
    for letter in text_fact:
        summ.append(int(letter))
    print(sum(summ))
    648
KUPRIENKO