[Java] 使用递归求n的阶乘 →→→→→进入此内容的聊天室

来自 , 2021-01-12, 写在 Java, 查看 130 次.
URL http://www.code666.cn/view/86df7dcf
  1. package com.bjsxt.zhp;
  2. /**
  3.  *      1、使用递归求n!
  4.  *             
  5.  * @author Administrator
  6.  *  1,使用for循环算出 5!
  7.  *  5! 5*4! 4! 4*3! 3 3*2! 2 2*1!  1!=1;
  8.  */
  9. public class Test8 {
  10.        
  11.         public static void main(String[] args) {
  12.                 /*      int result=1;
  13.                 for (int i = 1; i <=5; i++) {
  14.                                 result = i*result;
  15.                 }      
  16.                 System.out.println(result);*/
  17.                 int fn = fn(9);
  18.                 System.out.println(fn);
  19.         }
  20.        
  21. }

回复 "使用递归求n的阶乘"

这儿你可以回复上面这条便签

captcha