Sieve of Eratosthenes

Published by Matt in

Given num as input, return a list with all primes up to num included.

Alternative Text

Examples

eratosthenes(1) ➞ []

eratosthenes(10) ➞ [2, 3, 5, 7]

eratosthenes(20) ➞ [2, 3, 5, 7, 11, 13, 17, 19]

eratosthenes(0) ➞ []

Notes

  • Check the Resources tab for info on the meaning of "Eratosthenes".
  • Try solving this challenge using Eratosthenes sieve.
Watch a quick demo on how Edabit works.