1. Engineering
  2. Computer Science
  3. write a recursive c program to solve the following problem...

Question: write a recursive c program to solve the following problem...

Question details

Write a recursive C++ program to solve the following problem :

P(1) = 3

P(2) = 4

P(n) =P(n-1)+P(n-2) for n>2

To test – output for P(4)=11 P(6) = 29 and P(7) =47

Hint: main shall call a function int par(int n) that returns 3 if n=1, it returns 4 if n = 2, and it returns par(n-1) + par(n-2) if n>2

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution