diff options
Diffstat (limited to 'euler_686.py')
-rw-r--r-- | euler_686.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/euler_686.py b/euler_686.py new file mode 100644 index 0000000..01af7b2 --- /dev/null +++ b/euler_686.py @@ -0,0 +1,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() |