Advertisement
Guest User

factorial_habr

a guest
Feb 21st, 2011
1,572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  1. #include <stdio.h>
  2. int factorial(int n) {
  3. if (n == 0)
  4. return 1;
  5. return n * factorial (n - 1);
  6. }
  7. int main () {
  8. int i;
  9. int n;
  10. for (i = 0; i < 10; ++i) {
  11. n = factorial (i);
  12. printf ("factorial(%d) = %d\n", i, n);
  13. }
  14. return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement