Factorial digit sum
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!
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!
This problem is similar to Problem 16 Power digit sum.
I am not going to explain any part of this post as it is direct application of python programming to get the solution.
Program
Program is as follows:
If you want to download above program then you can download it from Github Gist pep20.py
Output
Summary
This problem is very simple if you were to solve it using python. I am not sure of other programming languages because you will face problems with long numbers. I think the question has been framed keeping in mind the long numbers in other programming language. Anyways looking at other side, the question has been framed to brush up our concepts in python.
As always if you have any doubt or didn't understand anything comment in the comment box below and I will be glad to help you.
Please do comment if you have found a typo or have a better/different program.
You can also contact me.
Thank you.