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

Given question is in attachment
What did the policy of internment reveal about the United States? What were the impacts of internment on Japanese Americans in the years and decades following t
WILL GIVE BRAINLIEST IF ANSWERED FAST!!!
One of the acute angles of a right triangle is 36 degrees. Find the other acute angle.
in the figure below PQRS is a parallelogram. Find the values of x y and z.​
24-6+7 multiply by 7
The Royal Botanical Gardens at Kew were famous because they were designed by a king. - True - False Answer: False (edg 24')
How many milliliters of Cleocin are needed to complete this order? Available: 900mg/3ml Order: 0.75g
Question 1a. The following equation models the spread of a disease: Where: N(t) is the number of people infected at the time. N0 is the initial number of i
it states us to compare two columnsplease help me​