diff --git a/e025.py b/e025.py new file mode 100644 index 0000000..b0dab1b --- /dev/null +++ b/e025.py @@ -0,0 +1,14 @@ +def fibonacci(n, limit=None): + fibonacci = [0, 1] + i = 2 + while i <= n: + f = fibonacci[i - 1] + fibonacci[i - 2] + fibonacci.append(f) + if limit and f >= limit: + return (i, fibonacci[-1]) + i = i + 1 + return (n, fibonacci[n]) + +if __name__ == '__main__': + (term, value) = fibonacci(10**999, 10**999) + print 'First Fibonacci term with at least 1000 digits is #{0}: {1}'.format(term, value)