|
|
|
|
|
by km6GEwiQqsyEKQH
1545 days ago
|
|
lim = 10**1000000
a, b = 1, 2
acc = 0
while a < lim:
if not a & 1:
acc += a
a, b = b, (a + b)
print("done", flush=True)
print(acc)
For a baseline this trivial python implementation does it in 34 ms for 10^10000 and 2m55 for 10^1,000,000 on a ryzen 5.
Because the fibonacci sequence is increasing roughly exponentially, the iteration count scales
roughly linearly to the number of digits. Then it just goes down to the number crunching speed of the bignum implementation?
(Calculating the exponent also takes multiple seconds, as well formatting the number to a string takes around 10 seconds as well.) |
|