import java.util.Scanner; public class Whilejc { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println("欢迎使用求阶乘计算器,请输入一个整数"); int a = s.nextInt(); int d = a; int b = a-1; int c = a*b; while(b>1) { a = b; b--; c= c*b; } System.out.println(d+"的阶乘是"+c) ; } }
用while语句打印阶乘
猜你喜欢
转载自www.cnblogs.com/lsswudi/p/11293928.html
今日推荐
周排行