Dain1234 / Design-and-analysis-algorithm

0 stars 0 forks source link

Factorial of a given number #5

Open Dain1234 opened 2 years ago

Dain1234 commented 2 years ago

Screenshot (48)

Dain1234 commented 2 years ago

include

long factorial(int n) { if (n == 0) return 1; else return(n * factorial(n-1)); }

void main() { int number; long fact; printf("Enter a number: "); scanf("%d", &number);

fact = factorial(number); printf("Factorial of %d is %ld\n", number, fact); return 0; }