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

What is the similarity ratio of the smaller to the larger prisms? Enter your answer as a:b
By 1938, Jews in Nazi Germany were not allowed to work in the government or carry identification. live near other Jews. attend synagogues. attend schools and c
The chain of events in a story is known as the
Completa el espacio en blanco con la forma correcta del verbo. Es importante que nosotros ________ ocho horas cada día. (dormir) durmemos duermamos dormamos
PLZ HELP ASAP INSCRIBED SHAPES
ಠ_ಠ Need HELP ಠ_ಠ Element A has 15 protons. Determine the number of neutrons in its isotope with mass number 33. a) 15 b)18 c)33 d)48
Identify the coefficient of each term of the polynomial. -2x+9  what is The coefficient of the first term is ....  what isThe coefficient of the second term is
a teacher says she has identified an organism with these characteristics eukaryotic brainly
How much space something take up? The answer from the photo
the word cultivated has several different meanings. which one is being used in the passage ?