File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ # Finding the factorial.
2+ def factorial (n ):
3+ fact = 1
4+ for i in range (1 ,n + 1 ):
5+ fact *= i
6+ return fact
7+
8+ # Spliting the digits and adding it.
9+ def split_and_add (number ):
10+ sum_of_digits = 0
11+ while (number > 0 ):
12+ last_digit = number % 10
13+ sum_of_digits += last_digit
14+ number = int (number / 10 ) # Removing the last_digit from the given number.
15+ return sum_of_digits
16+
17+ # Taking the user input.
18+ number = int (input ("Enter the Number: " ))
19+
20+ # Assigning the factorial from the factorial function.
21+ factorial = factorial (number )
22+
23+ # Spliting and adding the factorial into answer.
24+ answer = split_and_add (factorial )
25+
26+ # Printing the answer.
27+ print (answer )
Original file line number Diff line number Diff line change @@ -52,3 +52,7 @@ PROBLEMS:
5252
535316 . 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
5454 What is the sum of the digits of the number 2^1000?
55+ 20 . n! means n × (n − 1) × ... × 3 × 2 × 1
56+ For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
57+ and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
58+ Find the sum of the digits in the number 100!
You can’t perform that action at this time.
0 commit comments