{
if(x & gt; 1)
Return? x+fun(x- 1);
other
Return? x;
}
void main()
{
int? Sum;
sum = fun( 100);
printf("sum=%d\n ",sum);
}
Extended data
In the programming language, the function func (type A, ...) directly or indirectly calls the function itself, so the function is called recursive function. Recursive functions cannot be defined as inline functions.
Mathematically, the definition of recursive function is as follows: for a certain function f(x), its domain is set A, so if a certain value X0 in set A is determined by f(x0), then f(x) is called recursive function.
Functions with statements that directly or indirectly call this function are called recursive functions. In the above example, it can be seen that it must meet the following two conditions:
1) Every time I call myself, it must be (in a sense) closer to the solution;
2) There must be a standard for terminating processing or calculation.
Resources Baidu Encyclopedia-Recursive Function