8000 Good Fibonacci function implementation. · agamara/practice-python@88afcd9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 88afcd9

Browse files
committed
Good Fibonacci function implementation.
1 parent 8ccce90 commit 88afcd9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

experiments/fib_improved.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
3+
def fib(n):
4+
a, b = 1, 1
5+
for i in range(1, n):
6+
a, b = b, a + b
7+
8+
return a
9+
10+
11+
def main():
12+
for i in range(1, 15):
13+
print("fib({}) is {}".format(i, fib(i)))
14+
15+
16+
if __name__ == '__main__':
17+
main()

0 commit comments

Comments
 (0)
0