{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "12524157eec6409ab1b5e93fc9141608",
  "keywords": "算法高阶,数论算法,素数的测试,算法问题选编",
  "title": "求素数",
  "desc": [
    {
      "content": "\n求1-100内的素数",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "java"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "java"
      }
    ],
    [
      {
        "content": "",
        "language": "java"
      }
    ],
    [
      {
        "content": "",
        "language": "java"
      }
    ]
  ],
  "template": {
    "content": "public static void main(String[] args){\n\t\tfor(int i=0;i<100;i++) {\n\t\t\tcheckPrime(i);\n\t\t}\n\t}\n\tprivate static void checkPrime(int x){\n\t\tboolean isPrime = true;\n\t\tif(x ==1 || x %2 ==0 && x !=2 )\n\t\t{\n\t\t\tisPrime = false;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor( int i =3; i< Math.sqrt(x); i+=2)\n\t\t\t{\n\t\t\t\tif( x % i == 0)\n\t\t\t\t{\n\t\t\t\t\tisPrime = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif( isPrime)\n\t\t{\n\t\t\tSystem.out.println(x +\"是素数\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSystem.out.println(x+ \"不是素数\");\n\t\t}\n\t}",
    "language": "java"
  },
  "node_id": "dailycode-f0884125382f41c592c2346b73f34e30",
  "license": "csdn.net",
  "created_at": 1637894160,
  "topic_link": "https://bbs.csdn.net/topics/600470193"
}