/*
求5!
5! = 1*2*3*4*5;
*/
import java.util.*;
class JieChengDemo
{
public static void main(String[] args)
{
System.out.println("请输入需要求得阶乘数(整数):");
Scanner sc = new Scanner(System.in);
int z = sc.nextInt();
int amass = 1;//定义一个变量,用来表示乘积
for (int x = 1; x <= z ; x++ )
{
for (int y = 1; y <= z ; y++ )
{
if (y == x)
{
amass = amass*x;
}
}
}
System.out.println(z + "的阶乘是:" + amass);
}
}
|
|