标签:java factor nbsp long pac == oid tor lse
package com.homework.test; /* 【程序 22 递归求阶乘】 题目:利用递归方法求 5!。 程序分析:递归公式:fn=fn_1*4! */ public class Test22 { public static void main(String [] args){ int n = 5; System.out.println(factorial(n)); } public static long factorial(int n){ long Sum = 0; if (n == 1) Sum = 1; else Sum = n*factorial(n-1); return Sum; } }
标签:java factor nbsp long pac == oid tor lse
原文地址:https://www.cnblogs.com/lcpp/p/13051949.html