15,958,359 members
See more:
its about recursion and multiplying the even numbers

What I have tried:

int fn(){
int n;
n = rand() % 900 + 100;
printf("%d\n", n);
return 0;
}
Posted
Updated 22-Apr-20 0:00am
You forgot to mention the 2 questions as well as the problems you are having.
Patrice T 22-Apr-20 6:18am
And the questions are ?

## Solution 1

There is no recursion in that code: if `fn` was recursive, then it wouldn't work as there is no way to "limit" it from infinite recursion - you really need to parameter to do that, or you app will just blow the top off the stack and crash.
This is recursive:
C++
```int factorial(int n)
{
if (n <= 1) return 1;
return n * factorial(n - 1);
}```
Because it calls the `factorial` function from within the `factorial` function. Because the parameter value changes each time it gets called, the limiting check of "one or less" prevents infinite recursion, and it finally produces the correct result.

I'd suggest you go back to your course notes for the last lecture, and your homework question and read them again, really carefully!

v3