写一段java代码,计算22的阶乘
时间: 2024-03-10 09:49:54 浏览: 136
Java计算阶乘 源代码
下面是一个计算22的阶乘的Java代码示例:
```java
public class Main {
public static void main(String[] args) {
int n = 22;
long factorial = 1;
for (int i = 1; i <= n; i++) {
factorial *= i;
}
System.out.println(n + "的阶乘是:" + factorial);
}
}
```
输出结果为:
```
22的阶乘是:1124000727777607680000
```
阅读全文