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

To create the proper style for an argumentative essay, a writer should
what is the element line of ming plate of china​
Plz Help Me I Will Give Brainliest!! Use the passage to answer the following question: "I can see no reason to doubt but the imposition of taxes, whether on tra
Terry says the solution to 299 ÷ 40 is 6 with a remainder of 59. His work is shown below. Explain Terry’s error in thinking, and then find the correct quotient
WILL GIVE BRAINLIEST !! name the three different temperatures zones of ocean water
is space travel more realistic for individuals or organizations?
Question on the attachment.. Please help
meiosis makes __________ four cells
Make TWO claims each for how natural resources, transportation, and technology supported the post Civil War Industrial Revolution.
 Can someone pleaseeee help if you’re correct I’ll give u brainlist