Skip to content

Instantly share code, notes, and snippets.

@anemochore
Created February 5, 2017 17:19
Show Gist options
  • Save anemochore/b02d1c91304e005d77986e81e6159a0b to your computer and use it in GitHub Desktop.
Save anemochore/b02d1c91304e005d77986e81e6159a0b to your computer and use it in GitHub Desktop.
crude fibonacci solution
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