0
Why no output?
#include <iostream> using namespace std; int factorial(int n) { return n * factorial(n-1); } int main() { cout << factorial(5); }
7 Respostas
+ 6
Without base condition function will keep calling itself recursively infinite times.
+ 1
Hello. I think that your recursive function "factorial" is wrong. You need 'if (n==1) {return 1}'. Otherwise the function never stop.
0
Because you just created endless recursion. You have to write an assertion, when n reaches 0 to stop recursion.
0
I don't wont to make the end to this program
0
So you'll never get result then.
0
I wont to create endless recursion but no output
0
Okey, thanks)