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

Randolph carter, who had all his life sought to escape from the tedium and limitations
Mental illness and mental health imply that psychological disturbance or abnormality is like a ____ (fill in the blank) WILL MARK BRAINLIEST.
What integer represents a credit of $35 if zero represents the original balance? Explian
How do you know if the price of a particular house fits your budget? A. the lender accepts your mortgage application B. by calculating yearly income and month
with all his gear, Neil Armstrong weighed 360 pounds on Earth. When he landed on the moon, he weighed 60 pounds. Why?
how do i find the area if this problem?
Synthetic Division is a simplified method of dividing polynomials by attaching coefficients. true or false
Which of the following statements is true? A: The slave trade harmed some African states, but benefited others. B:European traders introduced the slave tr
3(-1)(-1) - 2x-1x-2 + 4(-2)(-2)
What is the volume of 46.5 g of silver if the density is 10.5 g/ml?