Why should one use return =1 instead of 0? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why should one use return =1 instead of 0?

the first lesson explained that any number more than 0 in return gives an error. So how come when learning factorials the example the return is given as 1 and not 0.

5th Nov 2016, 2:11 PM
vinod nair
vinod nair - avatar
2 Answers
0
Returning zero is only necessary for the main function, but every other function u create can return any number. If u were to return zero in the recursion function u would be multiplying by zero and ur output would then be zero
16th Dec 2016, 8:31 PM
Angelo Paparazzi
Angelo Paparazzi - avatar
- 1
factorials
5th Nov 2016, 2:54 PM
mutyal priyanka