{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "86be439d4197480e82a4fb53964fe650",
  "keywords": "算法高阶,计算几何学,算法问题选编",
  "title": "计算阶乘的和",
  "desc": [
    {
      "content": "\n编写程序计算1！+2！+3！+...+n！，并输出计算结果。（要求：n从键盘输入，0<=n<=50，如果输入的n值不在此范围，提示再次输入）",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "java"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "java"
      }
    ],
    [
      {
        "content": "",
        "language": "java"
      }
    ],
    [
      {
        "content": "",
        "language": "java"
      }
    ]
  ],
  "template": {
    "content": "import java.util.*;\nimport java.lang.*;\nimport java.io.*;\nclass Ideone {\n\tpublic static double p(int x) {\n\t\tdouble r = 1.0;\n\t\tfor (int i = 2; i <= x; i++)\n\t\t\tr *= i;\n\t\treturn r;\n\t}\n\tpublic static void main(String[] args) throws java.lang.Exception {\n\t\tScanner s = new Scanner(System.in);\n\t\tint n = s.nextInt();\n\t\tif (n > 50 || n < 0) {\n\t\t\tSystem.out.println(\"不在范围！\");\n\t\t} else {\n\t\t\tdouble d = 0;\n\t\t\tfor (int i = 1; i <= n; i++)\n\t\t\t\td += p(i);\n\t\t\tSystem.out.println(\"结果=\" + d);\n\t\t}\n\t}\n}",
    "language": "java"
  },
  "node_id": "dailycode-f212de10cac247a4bab00cb73e61b645",
  "license": "csdn.net",
  "created_at": 1637894160,
  "topic_link": "https://bbs.csdn.net/topics/600469976"
}