blob: 01af7b260ebe230fc9605d6de56c2e61d30c827e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/usr/bin/pypy
import math
# calculate the length-l prefix of 2^n
def prefix_power2(n,l):
log = math.log10(2)*n
declog = log - math.floor(log)
return math.floor(pow(10,declog+l-1))
def main():
i = 0
count = 0
while count < 678910:
i = i + 1
if prefix_power2(i, 3) == 123:
count = count + 1
if count % 1000 == 0:
print("p({},{})={}".format(123,count,i))
print("p({},{})={}".format(123,count,i))
if __name__ == "__main__":
main()
|