Advertisement
monoteen

Factorial

Nov 4th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. double fact(int n);
  4.  
  5. int main(void)
  6. {
  7.     int i;
  8.    
  9.     for(i=0; i<500; i++)
  10.         printf("Factorial(%d) 함수 결곟 = %f\n", i, fact(i));
  11.    
  12.     return 0;
  13. }
  14.  
  15. double fact(int n)
  16. {
  17.     double result = 0;
  18.    
  19.     if(n <= 1)
  20.         result = 1;
  21.     else
  22.         result = n * fact(n-1);
  23.    
  24.     return result;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement