aubreejordan6952 aubreejordan6952
  • 04-07-2019
  • Computers and Technology
contestada

h(n)=h(n)+h(n-2)

h(2)=h(1)=h(0)=1, n>=2

Write a C++ function int h(int n)

Respuesta :

SerenaBochenek SerenaBochenek
  • 14-07-2019

Answer:

#include<iostream>

using namespace std;

int h(int i)

{

if(i==0 ||i==1||i==2)

 return 1;

else

 return(h(i-1)+h(i-2));

}

int main()

{

int n, result;

cout<<"Enter value for n:";

cin>>n;

result = h(n);

cout<<result;

}

Explanation:

The recurrence relation will be h(n)= h(n-1)+h(n-2), unless the recursion will not finish.

Ver imagen SerenaBochenek
Answer Link

Otras preguntas

NEED HELP Urgent!!!! Answer question on the image
Estimate the measure of angle 1 a. 40°b. 90°c. 140°d. 170°Thanks! :)​ (last time my answers were all bots)​
what was the main reason that urban planners placed parks in the middle of cities​
Find the next three terms of the arithmetic sequence 5, 11, 17, 23,... 29, 34,38 O 25,31,37 O 28, 33,38 O 29, 35, 41
Cuál es el valor de g(2.5)
How many prisoners were held in the POW camps in Texas and what type of work did they do ?
Select the pronoun whose antecedent is "Jane Goodall".
Find the value of x to the nearest tenth
Spanish-Write complete sentences using the cues and saber or conocer.
Which statement describes how the second Great Awakening promoted social reform movements? New religious ideas focused on people's ability to improve themselves