def primelist(end):
    """
    Returns a list of all primes in the range [0, end]

    https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
    """
    is_prime = [1] * (end + 1)
    is_prime[0] = 0
    is_prime[1] = 0
    for i in range(int(len(is_prime)**.5 + 1)):
        if is_prime[i]:
            index_length = (end - i*i) // i + 1
            is_prime[i*i::i] = [0] * index_length

    return [n for n, p in enumerate(is_prime) if p]