def calculate_primes(limit):
    """
    Calculates all primes <= limit.
    
    >>> calculate_primes(10)
    [2, 3, 5, 7]
    >>> calculate_primes(3)
    [2, 3]
    """
    limit += 1
    is_prime = [True]*limit
    is_prime[0] = False
    is_prime[1] = False
    primes = []
    for i in range(2, limit):
        if not is_prime[i]:
            continue
        primes.append(i)
        for j in range(2*i, limit, i):
            is_prime[j] = False
    return primes