diff --git a/#020:Factorial_digit_sum.py b/#020:Factorial_digit_sum.py new file mode 100644 index 0000000..bd91e4b --- /dev/null +++ b/#020:Factorial_digit_sum.py @@ -0,0 +1,16 @@ +def factorial(n): + res = 1; + for i in range (2, n + 1): + res *= i; + return (res); + +q = int(input()); +for i in range (q): + n = int(input()); + n = str(factorial(n)); + + total = 0; + for j in (n): + total += int(j); + + print (int(total)); diff --git a/README.md b/README.md index a8b34a1..fcdf574 100644 --- a/README.md +++ b/README.md @@ -82,4 +82,7 @@ ___ Find the maximum sum of numbers that can be obtained by starting at the top of a triangle of numbers and moving to adjacent numbers on the row below, for a given triangle. ___ ## Problem 19: Counting Sundays [Easy] -Find the number of Sundays that fell on the first of the month between two dates(both inclusive) \ No newline at end of file +Find the number of Sundays that fell on the first of the month between two dates(both inclusive) +___ +## Problem 20: Factorial digit sum [Easy] +Find the sum of the digits in the number N! \ No newline at end of file