def main(): n = 1 for f in fibonacci(): if len(str(f)) == 1000: print(n) break n += 1
import time from util import fibonacci start_time = time.time() total = 0 n = 1 while fibonacci(n) <= 4000000: if not fibonacci(n) % 2: total += fibonacci(n) n += 1 print(total) end_time = time.time() print("Time taken: {} ms".format(round((end_time - start_time) * 1000, 3)))
def main(): i = 1 while fibonacci(i) < 10 ** 999: i += 1 print i
def problem2(m): return sum(n for n in itertools.takewhile(lambda x: x < m, util.fibonacci()) if not n % 2)
def main(): total = sum(x for x in fibonacci(maximum=4000000) if x % 2 == 0) print(total)
import time from util import fibonacci start_time = time.time() k = 1 while len(str(fibonacci(k))) < 1000: k += 1 print(k + 1) end_time = time.time() print("Time taken: {} ms".format(round((end_time - start_time) * 1000, 3)))
def solve(): for i, term in enumerate(fibonacci()): if len(str(term)) >= 1000: return i + 1
"""What is the first term in the Fibonacci sequence to contain 1000 digits? """ from util import fibonacci for i, n in enumerate(fibonacci(10000)): if len(str(n)) == 1000: # +1 -> first two terms returned by our function are 1, 2 and not 1, 1 # +1 -> i goes from 0 up to ... print i + 2 break