Repository with assignments using the Test Informed Learning with Examples (TILE) method to integrate testing into existing programming courses for free.
Join our LinkedIN Community.
Use the following BibTeX entry to cite this work:
@INPROCEEDINGS{DVMB2023, author={Doorn, Niels and Vos, Tanja and Marín, Beatriz and Barendsen, Erik}, booktitle={2023 IEEE Conference on Software Testing, Verification and Validation (ICST)}, title={Set the right example when teaching programming: Test Informed Learning with Examples (TILE)}, year={2023}, volume={}, number={}, pages={269-280}, doi={10.1109/ICST57152.2023.00033} }
Write a generate_eratosthenes
function that, using the Sieve of Eratosthenes 1, obtains the prime numbers between 2 and 120.
The algorithm is based on having in a set the numbers between 2 and 120, and then eliminate from that set the multiples of 2, then those of 3, then those of 5, and so on. Pseudocode would be as can be seen below:
Create a set and initialize it with the numbers between 2 and 120
Initialize p to 2
As long as p is between 2 and 120
As long as p is not within the set
increase p
Initialize k to 2 * p
As long as k is less than 120
Eliminate k from the set
Update k to k + p
Increase p
To test your function, you can compare the numbers you obtain with those that appear below on this website.