human
Find two prime numbers with given sum | Generate all prime numbers less than n ..
Initialize all entries of boolean array as True . A value in isPrime [ i ] will finally be False if i is Not a prime , else True bool isPrime [ n + 1 ].
If isPrime [ p ] is not changed , then it is a prime.
Update all multiples of p.
Prints a prime pair with given sum.
Generating primes using Sieve.
Traversing all numbers to find first pair.
Driven program"
How can the above be solved in Python?
assistant
#Here is code to find two prime numbers with given sum and the other steps required.
 def SieveOfEratosthenes ( n , isPrime ) :
	isPrime [ 0 ] = isPrime [ 1 ] = False
	for i in range ( 2 , n + 1 ) :
		isPrime [ i ] = True
	p = 2
	while ( p * p <= n ) :
		if ( isPrime [ p ] == True ) :
			i = p * p
			while ( i <= n ) :
				isPrime [ i ] = False
				i += p
		p += 1
def findPrimePair ( n ) :
	isPrime = [ 0 ] * ( n + 1 )
	SieveOfEratosthenes ( n , isPrime )
	for i in range ( 0 , n ) :
		if ( isPrime [ i ] and isPrime [ n - i ] ) :
			print ( i , ( n - i ) )
			return
n = 74
findPrimePair ( n )