From 5024901379d4a6bc0d2ecc9338701395f85199ba Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Thu, 13 May 2021 20:05:58 +0800 Subject: 684,686,700 --- euler_686.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 euler_686.py (limited to 'euler_686.py') 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() -- cgit v1.2.3