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

Please help A stamp collection consists of 10 albums each containing 42 pages. How many stamps are in the total collection if 40 stamps fit on a page? (1) 92
Line and tone Using the word bank below, annotate Relativity to demonstrate that you understand where he is applying tone and line in clever ways Write a paragr
what is 1.8 in written notation
Please I urgently need help with this
Read the excerpt from "Finding Unity in the Alabama Coal Mines.” The coal companies, in response, recruited workers from as far as New York’s Ellis Island, wher
What to respond to “I was having a bad day and u made it way better”
Plss help meeeHow does her statement apply to a youth like you? How are you going to convince other people to be conscious of the way they perceive others? You
provide three critical evaluations of your own contribution to environmental health and safety in your community​
please answer i will give u brainless PLZZZZZZ
Plsss answer:(❤️:(!!!!!!!!!​