We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d3e1f92 commit e4c4f86Copy full SHA for e4c4f86
src/topinterviewquestions/Problem_0204_CountPrimes.java
@@ -12,29 +12,12 @@ public static int countPrimes(int n) {
12
if (f[i]) {
13
continue;
14
}
15
-
16
- // 1
17
-// int cur = i;
18
-// int j = i;
19
-// int p = cur * j;
20
-// while (p < n) {
21
-// if (!f[p]) {
22
-// --count;
23
-// f[p] = true;
24
-// }
25
-// cur += 2;
26
-// p = j * cur;
27
28
29
30
- // 2
31
for (int j = i * i; j < n; j += 2 * i) {
32
if (!f[j]) {
33
--count;
34
f[j] = true;
35
36
37
38
39
return count;
40
0 commit comments