package cn.itcast_02;/* * 需求:請用代碼實現求5的階乘 * 下面的知識要知道: * 5! = 1*2*3*4*5 * 5! = 5*4! * * 有幾種方案實現呢? * A:循環實現 * B:遞歸實現 */public class DiGuiDemo { public static void main(String[] args) { int jc = 1; for (int x = 2; x <= 5; x++) { jc *= x; } System.out.PRintln("5的階乘是:" + jc); }}
新聞熱點
疑難解答