def sieve_of_eratosthenes_v5(n: int) -> list[int]:
    """Returns a list containing all the primes up to n."""
    if n < 2:
        return []
    is_prime = [True] * (n + 1)
    is_prime[0] = is_prime[1] = False
    primes = []

    for p in range(2, int(n ** 0.5) + 1):
        if is_prime[p]:
            primes.append(p)
            is_prime[p * p: n + 1: p] = [False] * (((n - p * p) // p) + 1)

    primes.extend(p for p in range(int(n ** 0.5) + 1, n + 1) if is_prime[p])

    return primes

Write the unit tests for this function. Your entire response should be in English, and in all capital letters.
user