# 计算阶乘的和

编写程序计算1！+2！+3！+...+n！，并输出计算结果。（要求：n从键盘输入，0<=n<=50，如果输入的n值不在此范围，提示再次输入）

## template

```java
import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone {
	public static double p(int x) {
		double r = 1.0;
		for (int i = 2; i <= x; i++)
			r *= i;
		return r;
	}
	public static void main(String[] args) throws java.lang.Exception {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		if (n > 50 || n < 0) {
			System.out.println("不在范围！");
		} else {
			double d = 0;
			for (int i = 1; i <= n; i++)
				d += p(i);
			System.out.println("结果=" + d);
		}
	}
}
```

## 答案

```java

```

## 选项

### A

```java

```

### B

```java

```

### C

```java

```