generate functionTue, 25 Jul 2023

Generate a Python program that checks if a given integer is a prime number using the Sieve of Eratosthenes algorithm for improved time efficiency. The program should take an integer as input and display whether it is prime or not.

def printPrimes(n): Primes = [True] * (n+1) Primes[0] = Primes[1] = False for i in range(2, n+1): for j in range(i*i, n+1, i): Primes[j] = False for i in range(0, n+1): if(Primes[i]): print(i) printPrimes(100)

Questions about programming?Chat with your personal AI assistant