File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/bin/python3
2
+
3
+ import math
4
+ import os
5
+ import random
6
+ import re
7
+ import sys
8
+
9
+ #
10
+ # Complete the 'superDigit' function below.
11
+ #
12
+ # The function is expected to return an INTEGER.
13
+ # The function accepts following parameters:
14
+ # 1. STRING n
15
+ # 2. INTEGER k
16
+ #
17
+
18
+ def recursiveSumStr (num ):
19
+ ints = [int (i ) for i in num ]
20
+ return sum (ints )
21
+
22
+ def recursiveSumInts (num ):
23
+ return sum ([int (i ) for i in str (num )])
24
+
25
+
26
+ def superDigit (n , k ):
27
+ # Write your code here
28
+ super_digit = 0
29
+
30
+ intermediate_digit = recursiveSumStr (n ) * k
31
+ while intermediate_digit % 10 != intermediate_digit :
32
+ intermediate_digit = recursiveSumInts (intermediate_digit )
33
+ return intermediate_digit
34
+
35
+
36
+
37
+
38
+
39
+ if __name__ == '__main__' :
40
+ fptr = open (os .environ ['OUTPUT_PATH' ], 'w' )
41
+
42
+ first_multiple_input = input ().rstrip ().split ()
43
+
44
+ n = first_multiple_input [0 ]
45
+
46
+ k = int (first_multiple_input [1 ])
47
+
48
+ result = superDigit (n , k )
49
+
50
+ fptr .write (str (result ) + '\n ' )
51
+
52
+ fptr .close ()
You can’t perform that action at this time.
0 commit comments