Skip to content

Commit 68ecb84

Browse files
authored
Create NthFibonacci.py
1 parent 07a65dc commit 68ecb84

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

NthFibonacci/NthFibonacci.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
2+
3+
import sys
4+
5+
def fib(N):
6+
a = 0
7+
b = 1
8+
for _ in range(N):
9+
a, b = b, a+b
10+
return a
11+
12+
if __name__ == '__main__':
13+
if len(sys.argv) >= 2:
14+
print(fib(int(sys.argv[1])))
15+
else:
16+
print(fib(int(input())))

0 commit comments

Comments
 (0)