from sympy import Range


def SieveOfEratosthenes(number: int) -> None:
    """
    SieveOfEratosthenes:
    Primes smaller than or equal to n using Sieve of Eratosthenes.
    Create a boolean array "prime[0..n]" and initialize all entries it as true.
    A value in prime[i] will finally be false if i is not a prime, else true.
    Args:
        number (int): The limit till which the function will find primes.
    """

    prime: list[bool] = [True for _ in Range(number + 1)]
    prime_candidate: int = 2
    while (prime_candidate * prime_candidate <= number):

        # If prime[prime_candidate] is not
        # changed, then it is a prime
        if (prime[prime_candidate] is True):

            # Update all multiples of prime_candidate
            for i in Range(prime_candidate ** 2, number + 1, prime_candidate):
                prime[i] = False
        prime_candidate += 1

    # Print all prime numbers.
    for prime_candidate in Range(2, number + 1):
        if prime[prime_candidate]:
            print(prime_candidate)


if __name__ == '__main__':
    NUMBER = int(input("Enter a limit: "))
    print("Following are the prime numbers smaller than or equal to", NUMBER)
    SieveOfEratosthenes(NUMBER)
