Skip to content

Commit 443a120

Browse files
committed
Revise sieve's exercise instructions
1 parent 47b3bb2 commit 443a120

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

exercises/sieve/instructions.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,27 @@ A prime number is a number larger than 1 that is only divisible by 1 and itself.
66
For example, 2, 3, 5, 7, 11, and 13 are prime numbers.
77
By contrast, 6 is _not_ a prime number as it not only divisible by 1 and itself, but also by 2 and 3.
88

9-
To use the Sieve of Eratosthenes, you first create a list of all the numbers between 2 and your given number.
10-
Then you repeat the following steps:
9+
To use the Sieve of Eratosthenes, first, write out all the numbers from 2 up to and including your given number.
10+
Then, follow these steps:
1111

12-
1. Find the next unmarked number in your list (skipping over marked numbers).
12+
1. Find the next unmarked number (skipping over marked numbers).
1313
This is a prime number.
1414
2. Mark all the multiples of that prime number as **not** prime.
1515

16-
You keep repeating these steps until you've gone through every number in your list.
16+
Repeat the steps until you've gone through every number.
1717
At the end, all the unmarked numbers are prime.
1818

1919
~~~~exercism/note
20-
The tests don't check that you've implemented the algorithm, only that you've come up with the correct list of primes.
21-
To check you are implementing the Sieve correctly, a good first test is to check that you do not use division or remainder operations.
20+
The Sieve of Eratosthenes marks off multiples of each prime using addition (repeatedly adding the prime) or multiplication (directly computing its multiples), rather than checking each number for divisibility.
21+
22+
The tests don't check that you've implemented the algorithm, only that you've come up with the correct primes.
2223
~~~~
2324

2425
## Example
2526

2627
Let's say you're finding the primes less than or equal to 10.
2728

28-
- List out 2, 3, 4, 5, 6, 7, 8, 9, 10, leaving them all unmarked.
29+
- Write out 2, 3, 4, 5, 6, 7, 8, 9, 10, leaving them all unmarked.
2930
- 2 is unmarked and is therefore a prime.
3031
Mark 4, 6, 8 and 10 as "not prime".
3132
- 3 is unmarked and is therefore a prime.
@@ -39,4 +40,4 @@ Let's say you're finding the primes less than or equal to 10.
3940
- 9 is marked as "not prime", so we skip over it.
4041
- 10 is marked as "not prime", so we stop as there are no more numbers to check.
4142

42-
You've examined all numbers and found 2, 3, 5, and 7 are still unmarked, which means they're the primes less than or equal to 10.
43+
You've examined all the numbers and found that 2, 3, 5, and 7 are still unmarked, meaning they're the primes less than or equal to 10.

0 commit comments

Comments
 (0)