1、package New;public class P02 / 1、实现阶乘public static void main(String args) P02 p = new P02();int i = p.JieCheng(5);System.out.print(i);public int JieCheng(int i) if (i = 1) return 1;return i * JieCheng(i - 1);/ 2、阶乘的实现/ public static void main(String args) / BigInteger bi=new BigInteger(“1“);/ for (i
2、nt i = 1; i = 5; i+) / BigInteger b=new BigInteger(String.valueOf(i);/ bi=bi.multiply(b);/ / System.out.println(“5的阶乘的为:“+bi);/ / 3、阶乘的实现/ public static void main(String args) / P02 p = new P02();/ long aa = p.add(5);/ System.out.println(aa);/ / public long add(long i) / if (i = 0 | i = 1) / return 1;/ else / i = i * add(i - 1);/ / return i;/