How many
times is the factorial fonction given below.
invoked for factorial (5)
def factorial (n):
if n == 0; # Base lase
return 1
else:
return n*factorial (n-1)
Answers
Answered by
0
Explanation:
long factorial(int);
int main() { int n;
printf("Enter a number to calculate its factorial\n"); scanf("%d", &n);
printf("%d! = %ld\n", n, factorial(n));
return 0; }
long factorial(int n) { int c; long r = 1;
for (c = 1; c <= n; c++) r = r * c;
return r; }
Similar questions