human
Write me a code to sieve of Eratosthenes and the other steps required given the following:
Sieve of Eratosthenes | Python program to print all 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 ..
If prime [ p ] is not changed , then it is a prime.
Update all multiples of p.
Print all prime numbers.
Driver code"
Solution in Python:
assistant
#Here is code to sieve of Eratosthenes and the other steps required.
 def SieveOfEratosthenes ( n ) :
	prime = [ True for i in range ( n + 1 ) ]
	p = 2
	while ( p * p <= n ) :
		if ( prime [ p ] == True ) :
			for i in range ( p * p , n + 1 , p ) :
				prime [ i ] = False
		p += 1
	for p in range ( 2 , n + 1 ) :
		if prime [ p ] :
			print p ,
if __name__ == ' _ _ main _ _ ' :
	n = 30
	print " Following ▁ are ▁ the ▁ prime ▁ numbers ▁ smaller " ,
	print " than ▁ or ▁ equal ▁ to " , n
	SieveOfEratosthenes ( n )