mirror of
https://github.com/correl/euler.git
synced 2024-11-27 19:19:50 +00:00
Problem 025
git-svn-id: file:///srv/svn/euler@54 e5f4c3ec-3c0c-11df-b522-21efaa4426b5
This commit is contained in:
parent
87d2ab997d
commit
4faaf8c80a
1 changed files with 14 additions and 0 deletions
14
e025.py
Normal file
14
e025.py
Normal file
|
@ -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)
|
Loading…
Reference in a new issue