+ 1
What is wrong with this code?
I have written a code to compute the factorial of numbers but is showing errors. https://code.sololearn.com/cpJzFyX8VU7i/?ref=app
10 Answers
+ 5
Hi! You can see and analize this code:
https://code.sololearn.com/cggT1zkn0027/?ref=app
+ 4
Well, if your method returns an int value, your method must be int type; if your method returns a float value, your method must be float type; etc.
+ 3
To make your recursive factorial function work, you need to have a return statement:
if (n == 1) return 1;
return n * factorial(n - 1);
+ 3
No Kavish Bamboli . Take a look at what Nimrod A. HolguĂn L. posted, and hopefully you will understand what I am talking about. Good luck!
+ 3
And if your method doesnât return a value, it must be "void".
+ 3
You're welcome, Kavish Bamboli! đ
+ 2
Yup, Thank you very much for your help Nimrod A. HolguĂn L. & Zeke Williams
+ 2
Of course Kavish Bamboli ! Happy Coding to you both.
+ 1
So, the point is that the method must be of an int type that returns a value
0
It is the same thing. You use method of type int or void, it is going to return the same value