fork download
  1. #include <stdio.h>
  2. int count = 0;
  3. void hanoi(int n, int from, int to,int middle){
  4. int c;
  5. printf("n = %d\n",n);
  6. if(n==1){
  7. count++;
  8. printf("%d번째 from %d to %d\n",n,from,to);
  9. }else{
  10.  
  11. hanoi(n-1,from,middle,to);
  12.  
  13. printf("%d번째 from %d to %d\n",n,from,to);
  14. count++;
  15. hanoi(n-1,middle,to,from);
  16. }
  17. }
  18. int factorial(int n){
  19. int result =1;
  20. if(n<=1){
  21. return 1;
  22. }else{
  23.  
  24. return n*factorial(n-1);
  25. }
  26. }
  27.  
  28. int main(void) {
  29. // your code goes here
  30. int n;
  31. int result =0;
  32. n=5;
  33. // hanoi(n,1,3,2);
  34. // printf("%d\n",count);
  35. result =factorial(n);
  36. printf("%d\n",result);
  37. return 0;
  38. }
  39.  
Success #stdin #stdout 0s 2008KB
stdin
Standard input is empty
stdout
120