-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem48.py
More file actions
55 lines (32 loc) · 1008 Bytes
/
Copy pathproblem48.py
File metadata and controls
55 lines (32 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import time
from mymodule import calculate_time
from mymodule import is_prime
#########################################################################3
def power_mode(a, b, c): # return a^b mode c
modval = a%c
temp = modval
for i in range(1, b):
temp = (temp * modval) % c
return temp
def nth_digit(a,b, n): #a^b
return int((power_mode(a, b, 10**(n)) - power_mode(a, b, 10**(n-1)))/10**(n-1))
def test():
return
#########################################################################3
@calculate_time
def main():
digit48 = ""
recall = 0
for i in range(1,11):
sdigits = 0
for j in range(1, 1001):
dj = nth_digit(j, j, i)
sdigits += dj
sdigits += recall
print(sdigits)
digit48 = str(sdigits % 10) + digit48
recall = int(sdigits/10)
print(digit48)
return 0
if __name__ == "__main__":
main()