UMBC CMSC 201 Fall '05 CSEE | 201 | 201 F'05 | lectures | news | help |
#include <stdio.h> int Factorial (int n); int main() { int fact, n; printf("Enter a positive integer : "); scanf("%d", &n); fact = Factorial(n); printf("%d\n", fact); return 0; } /************************* * Factorial() finds the factorial of the number, * n, passed in using recursion. * * Input: The integer n to find the factorial of * Output: Returns n! ************************/ int Factorial (int n) { if (n == 0) { return (1); } else { return (n * Factorial (n - 1)); } }