Created
February 5, 2017 17:19
-
-
Save anemochore/b02d1c91304e005d77986e81e6159a0b to your computer and use it in GitHub Desktop.
crude fibonacci solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = input() | |
if not a.isdigit() or len(a) == 0: | |
print('n should be a number') | |
quit() | |
n = int(a) | |
if n < 2: | |
print('n should be >= 2') | |
quit() | |
fibo_array = [0, 1] | |
print("fibonacci {0} = {1}".format(1, fibo_array[1])) | |
for i in range(2, n + 1): | |
fibo_array.append(fibo_array[i - 1] + fibo_array[i - 2]) | |
print("fibonacci {0} = {1}".format(i, fibo_array[i])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment