File tree 3 files changed +49
-0
lines changed
3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ power = int (input ("Enter the power of 2: " ))
2
+ num = 2 ** power
3
+
4
+ string_num = str (num )
5
+
6
+ list_num = list (string_num )
7
+
8
+ sum_of_num = 0
9
+
10
+ print ("2 ^" ,power ,"=" ,num )
11
+
12
+ for i in list_num :
13
+ sum_of_num += int (i )
14
+
15
+ print ("Sum of the digits are:" ,sum_of_num )
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 @@ -49,3 +49,10 @@ PROBLEMS:
49
49
Using the rule above and starting with 13, we generate the following sequence:
50
50
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
51
51
Which starting number, under one million, produces the longest chain?
52
+
53
+ 16 . 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
54
+ 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