+ 3
Inaccurate function
The factorial of 0 is 1, its a small detail but the code doesnt account for it
3 Respuestas
+ 4
It is hard to answer because you didn't mention your code. Anyways, this mistake is possible.
int factorial (int num) {
if (num ==1)
return 1;
else
return n * factorial(n - 1);
}
I think that you used the above code for factorial function. The least number for which it works is 1 because of the condition (num == 1). If you replace it with (num <= 1), the function works for 0 too.
+ 3
show your code
0
oh i meant this as an answer to the example code, im not quite sure how this discussions section works heh