The clearance required to write Fun recursive function (n) to implement the function Fun shown below, wherein n is a positive integer, if the input is not a positive integer, output "non-positive integer."
related information
What is a recursive function
I.e., from the recursive function calls the function, in the functions that calls itself directly or indirectly, i.e. nesting function calls is the function itself.
Description of function call mechanism
Defined between any of the functions can not be nested, independent of each other (one another can be called) between the calling function and the callee function. Function call occurs, the called function in the protection of environment and the operation function call return address, so that the state of the calling function may be fully restored after the operation is returned to the called function, and regardless of the state of the called function.
The code is run, although the called function is a function of the same body of code, but the point of call, the call state, returns at different points, can be seen as a copy function, regardless of the code calls the function, the code function is independent. Stack space is running the called function is independent of the function call stack space, so the call data between functions is irrelevant. By passing parameters and return values to the links between functions, considered as a black box function.
In the form of recursive calls
Recursive call recursive call direct and indirect recursive calls in two forms.
Direct recursive function calls itself appears in the function.
Indirect recursive call is a function call other functions, but other functions which call this function.
Programming requirements is to present related programming tasks complement step1 / RecSegFunCal.cpp file Fun function to achieve the required segment seeking function values.
int Fun(int n)
{
if(n<=3)
{
return n;
}
else
{
return Fun(n-1)+Fun(n-3);
}
}