def get_primes(n):
    """Get all primes less than or equal to n."""
    if n < 2:
        return []
    primes = [2]
    for i in range(3, n+1):
        for p in primes:
            if i % p == 0:
                break
            if p > int(i ** 0.5):
                primes.append(i)
                break
    return primes