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 08b2ca4 commit d989e12Copy full SHA for d989e12
solution/204.Count Primes/Solution.js
@@ -0,0 +1,31 @@
1
+// 600ms多
2
+const countPrimes2 = function(n){
3
+ let arr = [];
4
+ let res = 0;
5
+ for(let i = 2; i < n; i++){
6
+ if(arr[i] === undefined){
7
+ arr[i] = 1;
8
+ res++;
9
+ for(let j = 2; i * j < n; j++){
10
+ arr[i * j] = 0;
11
+ }
12
13
14
+ return res;
15
+};
16
+
17
+//200ms多
18
+const countPrimes = function(n){
19
20
21
22
23
24
25
+ for(let j = i; i * j < n; j++){
26
27
28
29
30
31
0 commit comments