Project Euler

Problem 20: Factorial digit sum

Find the sum of the digits in the number 100! Run this solution at repl.io here.

      
        def factorial(n):
          if n == 1:
            return n
          else:
             return(n*factorial(n-1))

        #turn the digits of 100! into a list of strings
        flist = list(str(factorial(100)))

        #make a new list of integers from the strings of flist
        flist = list(map(int, flist))

        #output sum of the strings in the list
        print(sum(flist))
      
    

back to code menu