Question: Define a function new_fib that computes the n-th Fibonacci number using the function combine . def combine(f, op ,n): result = f(0) for i in

Define a function new_fib that computes the n-th Fibonacci number using the functioncombine.

def combine(f, op ,n):

result = f(0)

for i in range(n):

result = op(result, f(i))

return result

def new_fib(n):

def f(x):

##answer

return

def op(x, y):

##answer

return

return combine(f, op, n+1) #use this as return output - return statement

new_fib(1) 1

new_fib(2) 1

new_fib(3) 2

new_fib(10) 55

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!