JAVA/4. Array

ReculFactorial 예제

날아올라↗↗ 2016. 6. 22. 15:45
728x90
반응형
  1. package test.com;
  2.  
  3. public class ReculFactorial {
  4.  
  5.     public static void main(String[] args) {
  6.         // TODO Auto-generated method stub
  7.         //System.out.println("7 factorial : " + factorial(7));
  8.         factorial(7);
  9.     }
  10.    
  11.     public static int factorial(int n) {
  12.         if (n == 1)
  13.             return 1;
  14.         else
  15.             System.out.println(factorial(n-1));
  16.             return n*factorial(n-1);
  17.            
  18.     }
  19.  
  20. }


728x90
반응형