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

identify the function shown in this graph
How many protons does the element Li have
Help please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Please explain the answer clearly !!!
need help asap thank you !!
Our peak time this week will be 8:00 am to 12:00 pm, which requires 32% more agents than the afternoon requirements of 473 agents. " representative: "so, you wi
100 POINTS If you could use genetic engineering to create a new organism or to mass-produce a product, what would it be? Why did you choose this organism or pro
characteristics that make male race attractive.
to remember your age . take your house number and double it then add 5 and multiply by 50 the add your age and the number of days in a year and subtract 615 fro
subtract 6 from z, then multiply 3 by the resultDo not simplify any part of the expression.Help please