Program 1
Factorial
You are required to fix and write the logical part for the function and that takes an integer ‘n’ as input and returns the factorial of ‘n’ with recursion.
Incorrect Code
Correct Code
Incorrect Code
#include <iostream> unsigned long long factorial(int n) { if (n == 0) { return 1; } else {
} }
Correct Code
#include <iostream> unsigned long long factorial(int n) { if (n == 0 || n == 1) { return 1; } else { return n * factorial(n - 1); } }
coorect
Hey there,
Thanks for commenting.
end should be equal to mid -1
and start should be equal to mid +1;