Title Description
Description
Students often encounter this function when they do a problem.
F (x) =5 (x>=0)
F (x) =f (x+1) +f (x+2) +1 (x<0)
Let's do a recursive procedure with this function as a question.
Enter a description input Description
A number represents the X value in F (x)
Everybody notice just one number, the front represents the sample number
Outputs description output Description
A number represents a value
Everybody notice just one number, the front represents the sample number
Sample input to sample
Example one: 0
Sample two:-5
Sample output sample
outputs
Example one: 5
Sample two: 77
Data
size & Hint
X>=-30
One thing learned from this question is that negative numbers can be directly involved in integer arithmetic without conversion.
AC Code:
1#include <iostream>2 using namespacestd;3 4 intFintN) {5 intsum;6 if(n>=0)7sum=5;8 Else{9Sum=f (n+1) +f (n+2)+1;Ten } One returnsum; A } - intMain () { - intN; theCin>>N; -Cout<<f (n) <<Endl; - return 0; -}
1842 Recursive first time