Skip to content

Commit b57a1f2

Browse files
authored
Sync sieve docs with problem-specifications (#1640)
The sieve exercise has been overhauled as part of a project to make practice exercises more consistent and friendly. For more context, please see the discussion in the forum, as well as the pull request that updated the exercise in the problem-specifications repository: - https://forum.exercism.org/t/new-project-making-practice-exercises-more-consistent-and-human-across-exercism/3943 - exercism/problem-specifications#2216
1 parent 0a56964 commit b57a1f2

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed
Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
# Instructions
22

3-
Use the Sieve of Eratosthenes to find all the primes from 2 up to a given
4-
number.
3+
Your task is to create a program that implements the Sieve of Eratosthenes algorithm to find prime numbers.
54

6-
The Sieve of Eratosthenes is a simple, ancient algorithm for finding all
7-
prime numbers up to any given limit. It does so by iteratively marking as
8-
composite (i.e. not prime) the multiples of each prime, starting with the
9-
multiples of 2. It does not use any division or remainder operation.
5+
A prime number is a number that is only divisible by 1 and itself.
6+
For example, 2, 3, 5, 7, 11, and 13 are prime numbers.
107

11-
Create your range, starting at two and continuing up to and including the given limit. (i.e. [2, limit])
8+
The Sieve of Eratosthenes is an ancient algorithm that works by taking a list of numbers and crossing out all the numbers that aren't prime.
129

13-
The algorithm consists of repeating the following over and over:
10+
A number that is **not** prime is called a "composite number".
1411

15-
- take the next available unmarked number in your list (it is prime)
16-
- mark all the multiples of that number (they are not prime)
12+
To use the Sieve of Eratosthenes, you first create a list of all the numbers between 2 and your given number.
13+
Then you repeat the following steps:
1714

18-
Repeat until you have processed each number in your range.
15+
1. Find the next unmarked number in your list. This is a prime number.
16+
2. Mark all the multiples of that prime number as composite (not prime).
1917

20-
When the algorithm terminates, all the numbers in the list that have not
21-
been marked are prime.
18+
You keep repeating these steps until you've gone through every number in your list.
19+
At the end, all the unmarked numbers are prime.
2220

23-
The wikipedia article has a useful graphic that explains the algorithm:
24-
https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
21+
```exercism/note
22+
[Wikipedia's Sieve of Eratosthenes article][eratosthenes] has a useful graphic that explains the algorithm.
2523
26-
Notice that this is a very specific algorithm, and the tests don't check
27-
that you've implemented the algorithm, only that you've come up with the
28-
correct list of primes. A good first test is to check that you do not use
29-
division or remainder operations (div, /, mod or % depending on the
30-
language).
24+
The tests don't check that you've implemented the algorithm, only that you've come up with the correct list of primes.
25+
A good first test is to check that you do not use division or remainder operations.
26+
27+
[eratosthenes]: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
28+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Introduction
2+
3+
You bought a big box of random computer parts at a garage sale.
4+
You've started putting the parts together to build custom computers.
5+
6+
You want to test the performance of different combinations of parts, and decide to create your own benchmarking program to see how your computers compare.
7+
You choose the famous "Sieve of Eratosthenes" algorithm, an ancient algorithm, but one that should push your computers to the limits.

0 commit comments

Comments
 (0)