Skip to content

Commit 0ff5058

Browse files
committed
2 parents 31b5af1 + e668227 commit 0ff5058

File tree

1 file changed

+1
-2
lines changed
  • 1-js/2-first-steps/15-while-for/7-list-primes

1 file changed

+1
-2
lines changed

1-js/2-first-steps/15-while-for/7-list-primes/solution.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The code using a label:
1414

1515
```js run
1616
nextPrime:
17-
for (let i = 2; i < 10; i++) { // for each i...
17+
for (let i = 2; i <= 10; i++) { // for each i...
1818

1919
for (let j = 2; j < i; j++) { // look for a divisor..
2020
if (i % j == 0) continue nextPrime; // not a prime, go next i
@@ -25,4 +25,3 @@ for (let i = 2; i < 10; i++) { // for each i...
2525
```
2626

2727
Surely, there's a lot of space to opimize it. Like, we could look for the divisors from `2` to square root of `i`. But anyway, if we want to be really efficient for large intervals, we need change the approach and rely heavily on advanced maths and algorithms like [Quadratic sieve](https://en.wikipedia.org/wiki/Quadratic_sieve), [General number field sieve](https://en.wikipedia.org/wiki/General_number_field_sieve) etc.
28-

0 commit comments

Comments
 (0)