Everyone in the solutions are giving functions with if else statements and return statement which i don't want . I have clearly mentioned that there should be no if else and return statement . that's why in my program i also didn't use it
I want to know if we can write the factorial of a number using recursion without using any if-else statements and a return statement. If yes, then how?
I tried something like this:
int n;
int fact=1;
factorial(){
while(n){
fact= fact * n;
n--; factorial();
}
}
main(){
n = 5;
factorial();
printf("%d",fact);
}
The above program is correctly giving a factorial of the number but the recursive call is just a dummy here. The recursive call is not actually doing anything. So is it possible to write a factorial of a number with recursion without return statement & ifelse where recursive calls are actually contributing to find the factorial