kaitlynusery4159 kaitlynusery4159
  • 09-07-2020
  • Computers and Technology
contestada

Complete computeFibonacci() to return FN, where F0 is 0, F1 is 1, F2 is 1, F3 is 2, F4 is 3, and continuing: FN is FN-1 + FN-2.

Respuesta :

frknkrtrn
frknkrtrn frknkrtrn
  • 13-07-2020

Answer:

def computeFibonacci(n):

   if n == 0:

       return 0

   if n == 1:

       return 1

   else:

       return computeFibonacci(n-1) + computeFibonacci(n-2)

Explanation:

*The code is in Python.

Create a function called computeFibonacci that takes one parameter, n

If n is equal to 0, return 0

If n is equal to 1, return 1

Otherwise, return the total of the previous two numbers by calling the functions with parameters n-1 and n-2

Answer Link

Otras preguntas

My teacher never explained how to solve for x, can someone help me?
there are 2 dozen calories in a candy bar. Jason ate 8 candy bars.How many calories are there in 21 candy bars
The Great Awakening of the 18th century resulted in
Reagan’s landslide victory in 1980 was proof that there were more Republicans than Democrats in the United States. Americans were ready for a change in leadersh
What happened in wwl
How did the English head right system help populate the English colonies
Is 3y-4x=20 a function?
A laser produces 17.0 mW of light. In 4.00 hr , the laser emits 6.04×1020 photons. What is the wavelength of the laser?
Use the periodic to fill in the numbers in the electron configurations shown below. B: 1s2 2sA2pB
Before the signing of the _____________, the king of England had unlimited powers. A~ English Bill of Rights B~ Mayflower Compact C~ U.S. Constitution D~ Magna
good job