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

How has president trump changes America’s relationship with the world ?
Identify the graph and describe the solution set of this system of inequalities. y < –3x – 2 y > –3x + 8
In _____, each state is represented according to the size of its population.
List weight per volume
is Maine one of the 13 colonies
Where are languages seperated in the brain?
how to put the words in order and write complete sentences
A Sofa stores markup rate is 1/3 of the wholesales price. What is the wholesale price of a sofa if the markup is $90?
ehat is the additive inverse of the complex number 9-4i
An essential consumer skill is being able to ________________________. a. address problems with sellers. b. take legal action when necessary. c. look after y