用Java写一个10的阶乘
时间: 2023-11-23 17:05:54 浏览: 106
Java 编写的1到10的阶乘和
5星 · 资源好评率100%
Sure, here's the Java code to calculate 10 factorial:
```
public class Factorial {
public static void main(String[] args) {
int number = 10;
long factorial = 1;
for(int i=1; i<=number; i++){
factorial = factorial*i;
}
System.out.println("Factorial of "+number+" is: "+factorial);
}
}
```
When you run this code, it will print out the result: "Factorial of 10 is: 3628800".
阅读全文