Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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()
Add Comment
Please, Sign In to add comment