Apr-04-2019, 03:14 AM
I am having a hard time initiating this program
The idea of the Fibonacci sequence can be generalized by starting with any two numbers F0 and F1, and then continuing as in the Fibonacci sequence so that Fn = Fn-1 + Fn-2 for n>=2.
Use the Design Recipe to define a function gen_fibonacci that consumes three integer arguments. The first two arguments are the first two members of the sequence, and the third is the number of elements to print, each on its own line. Include a docstring!
For example:
Test
Displays
gen_fibonacci(2,5,5)
2
5
7
12
19
I started like this :
The idea of the Fibonacci sequence can be generalized by starting with any two numbers F0 and F1, and then continuing as in the Fibonacci sequence so that Fn = Fn-1 + Fn-2 for n>=2.
Use the Design Recipe to define a function gen_fibonacci that consumes three integer arguments. The first two arguments are the first two members of the sequence, and the third is the number of elements to print, each on its own line. Include a docstring!
For example:
Test
Displays
gen_fibonacci(2,5,5)
2
5
7
12
19
I started like this :
def gen_fibonacci(n,n2,n3): f1 = 0 f2 = 1 if n >= 1: print(f1) if n >= 2: print(f2) for i in range(2, n):thank you