Code

Use syntax coloring to better communicate code.

Sieve of Eratosthenes [1]
def eratosthenes(end, start=2, return_boolean=False):

    # Finds all primes < `end`.

    primes = []
    if end < start or end < 2:
        return []
    is_prime = [True for i in range(end + 1)]
    is_prime[0] = is_prime[1] = False
    for i in range(2, end + 1):
        if not is_prime[i]:
            continue
        if start <= i <= end:
            primes.append(i)
        j = i * i
        while j <= end:
            is_prime[j] = False
            j += i
    if return_boolean:
        return primes, is_prime
    return primes

1. Source: Github

Documents not found.