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

Which type of digital wallet maintains your e-commerce information on the seller's web site?
Why do scientists use binomial nomenclature?
The broom in this cartoon from early 1932 represents changes to the government, which people expected fdr to make. these were changes that would
Jamal is asked to write a science essay about molecular forces. He first turns to his science textbook for information. Which is the BEST second source for Jama
Which statement about work and power correctly describes an automobile race? The car do different amount of work depending on how fast they finish. The car that
a fair sold a total of 3,300 tickets on Friday and Saturday. It sold 100 more on Friday than on Saturday. How many tickets did the fair sell on Friday?
ASAP plz help thanks
onestitatea este cea mai bun?? politic?? eseu va rog repede dau coroana
(2+(-3)(5))(3+2(-6))
HELP PLS IM USING 99 POINTS QUESTION!!!!! What type of rock is pumice? Describe how a pumice rock is likely to change over a long period of time.