public class Factorial { public static void main(String[] args) { int n = 5; int result = 1; for (int i = n; i > 0; i--) { result *= i; } System.out.println(n + "的阶乘是:" + result); } }

// 输出结果为:5的阶乘是:120

java	计算n的阶乘n的阶乘是 nn-1n-2……1比如5的阶乘是54321要求输入数字n计算n的阶乘

原文地址: https://www.cveoy.top/t/topic/cJUW 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录