Skip to content

Commit 7124a3b

Browse files
kytrinyxBethanyG
authored andcommitted
Sync sieve docs with problem-specifications
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 ---- If you approve this pull request, I will eventually merge it. However, if you are happy with this change **please merge the pull request**, as it will get the changes into the hands of the students much more quickly.
1 parent bf2b5f1 commit 7124a3b

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +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 prime numbers up to any given limit.
7-
It does so by iteratively marking as composite (i.e. not prime) the multiples of each prime, starting with the multiples of 2.
8-
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.
97

10-
Create your range, starting at two and continuing up to and including the given limit.
11-
(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-
[This wikipedia article][eratosthenes] has a useful graphic that explains the algorithm.
21+
```exercism/note
22+
[Wikipedia's Sieve of Eratosthenes article][eratosthenes] has a useful graphic that explains the algorithm.
2423
25-
Notice that this is a very specific algorithm, and the tests don't check that you've implemented the algorithm, only that you've come up with the correct list of primes.
26-
A good first test is to check that you do not use division or remainder operations (div, /, mod or % depending on the 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.
2726
2827
[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)