使用递归的阶乘
import java.io.BufferedReader; import java.io.IOException;/* 来 自 nowjava - 时 代 Java*/ import java.io.InputStreamReader; public class Main { public static void main(String args[]) throws NumberFormatException, IOException{ int a = 10; int result= fact(a); System.out.println("Factorial of the number is: " + result); } static int fact(int b) { if(b <= 1)/* from n o w j a v a . c o m*/ //if the number is 1 then return 1 return 1;