递归算法 阶乘 JAVA描述

package arithmetic.digui;

import java.util.*;

public class Factorial {
 public static void main(String args[]) {

  Scanner scanner = new Scanner(System.in);
  int i = scanner.nextInt();
  System.out.println(getFactorial(i));
 }

 public static int getFactorial(int n) {
  if (n == 1)
   return 1;
  else
   return n * getFactorial(n - 1);
 }
}  

你可能感兴趣的:(算法,java,import,string,class)