recsee.c (513B)
1 /* Exercise 5.41 */ 2 3 #include <stdio.h> 4 5 long factorial(long number); 6 7 int main() 8 { 9 int i; 10 11 for(i = 0; i <= 10; i++) { 12 printf("%2d! = %ld\n\n", i, factorial(i)); 13 } 14 15 return 0; 16 } /* E0F main */ 17 18 /* Recursive definition of factorial() function */ 19 long factorial(long number) { 20 21 if(number) printf("=> %d * factorial(%d)\n", number, number - 1); 22 23 if(number <= 1) { 24 printf("===> ", " "); 25 return 1; 26 } 27 else 28 return number * factorial(number - 1); 29 30 } /* eof factorial() */ 31