We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1772b91 commit 20222fbCopy full SHA for 20222fb
Fibonacci.py
@@ -0,0 +1,18 @@
1
+# Write a program that asks the user how many Fibonnaci
2
+# numbers to generate and then generates them. Take this
3
+# opportunity to think about how you can use functions.
4
+# Make sure to ask the user to enter the number of numbers
5
+# in the sequence to generate
6
+
7
+def gen_fib(length, mylist = []):
8
+ if(len(mylist) < 2):
9
+ mylist.append(1)
10
+ else:
11
+ mylist.append(mylist[len(mylist)-1] + mylist[len(mylist)-2])
12
13
+ if(len(mylist) == length):
14
+ return mylist
15
16
+ return gen_fib(length, mylist)
17
18
+print(gen_fib(int(input("How many numbers of the Fibonacci sequence would you like to generate?\n"))))
0 commit comments