用while语句打印阶乘

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) ;
	}
}
原文地址:https://www.cnblogs.com/lsswudi/p/11293928.html