Skip to content

Instantly share code, notes, and snippets.

@Caesar-Victory
Created November 3, 2022 01:25
Show Gist options
  • Save Caesar-Victory/24f62f9b03b660f683c4bab4ea4ccacf to your computer and use it in GitHub Desktop.
Save Caesar-Victory/24f62f9b03b660f683c4bab4ea4ccacf to your computer and use it in GitHub Desktop.
#C++
#include <iostream>
using namespace std;
const int N = 100010;
int main(void) {
for (int i = 100000;; i++) {
bool flag = true;
// 排除1作为质数
for (int j = 2; j * j <= i; j++) {
// 取模是只能被自身整除
if (i % j == 0) {
flag = false;
break;
}
}
if (flag) {
cout << i << endl;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment