编写应用程序求1!+2!+....+10!
时间: 2023-11-24 14:06:54 浏览: 68
C#语言编写求1!+2!+...+10!的源程序
以下是Java语言编写的应用程序,用于求1!+2!+....+10!的和:
```java
public class FactorialSum {
public static void main(String[] args) {
int sum = 0;
for (int i = 1; i <= 10; i++) {
int factorial = 1;
for (int j = 1; j <= i; j++) {
factorial *= j;
}
sum += factorial;
}
System.out.println("1!+2!+...+10!=" + sum);
}
}
```
阅读全文