Fibonacci example (imperative)

This commit is contained in:
Claudio Maggioni 2019-02-19 13:23:03 +01:00
parent b07b6827ba
commit bf94a2b282

20
fibonacci.py Executable file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env python3
import sys
def F(n):
a = 0
b = 1
while n > 0:
c = a
a = a + b
b = c
n = n - 1
return a
def main():
for arg in sys.argv[1:]:
print("F(" + arg + "): " + str(F(int(arg))))
if __name__ == "__main__":
main()