Skip to content

Instantly share code, notes, and snippets.

@mtparagon5
Created November 21, 2017 04:15
Show Gist options
  • Save mtparagon5/1b049f27ff63859a4a0441352dcb1e4c to your computer and use it in GitHub Desktop.
Save mtparagon5/1b049f27ff63859a4a0441352dcb1e4c to your computer and use it in GitHub Desktop.
Unit_01_Lesson01_Assignment01
# creating a list of fibonacci numbers (capped at 20)
# adds the two previous numbers to equal the next
def get_fib_list_length():
return 20
def generate_fib(num):
result = []
for n in range(num):
if n == 0:
result.append(0)
elif n == 1:
result.append(1)
# else add n[index n-2] + n[index n-1]
else:
value = result[n-2] + result[n - 1]
result.append(value)
return result
def display_fibs(fibs):
for fib in fibs:
print(fib)
def main():
fib_limit = get_fib_list_length()
fibs = generate_fib(fib_limit)
display_fibs(fibs)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment