Prime List

Given num as input, return an array with all primes up to num included.

eratosthenes(1) ➞ []

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

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

eratosthenes(0) ➞ []Code language: CSS (css)
Scroll to Top