MCPcopy Create free account
hub / github.com/E869120/math-algorithm-book / main

Function main

codes/cpp/Code_4_04_1.cpp:7–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5bool prime[100000009];
6
7int main() {
8 // ���� �� �z��̏�����
9 cin >> N;
10 for (int i = 2; i <= N; i++) prime[i] = true;
11
12 // �G���g�X�e�l�X�̂ӂ邢
13 for (int i = 2; i * i <= N; i++) {
14 if (prime[i] == true) {
15 for (int x = 2 * i; x <= N; x += i) prime[x] = false;
16 }
17 }
18
19 // N �ȉ��̑f�������������ɏo��
20 for (int i = 2; i <= N; i++) {
21 if (prime[i] == true) cout << i << endl;
22 }
23 return 0;
24}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected