All primes up to n
mediumMaths and loops20 XP
Return all the prime numbers from 2 up to and including n, smallest first. For a fast answer, look up the Sieve of Eratosthenes.
Examples
- Input: n = 10Output: [2, 3, 5, 7]
- Input: n = 1Output: []
Examples use JSON: true/false/null are True/False/None in Python.