human
Insert minimum number in array so that sum of array becomes prime | function to check if a number is prime or not.
Corner case.
Check from 2 to n - 1.
Find prime number greater than a number.
find prime greater than n.
check if num is prime.
Increment num.
To find number to be added so sum of array is prime.
To find sum of array elements.
If sum is already prime return 0.
To find prime number greater than sum.
Return difference of sum and num.
Driver code"
How can the above be solved in Python?
 Write me a code to insert minimum number in array so that sum of array becomes prime and the other steps required?
assistant
#Here is code to insert minimum number in array so that sum of array becomes prime and the other steps required.
 def isPrime ( n ) :
	if n <= 1 :
		return False
	for i in range ( 2 , n ) :
		if n % i == 0 :
			return False
	return True
def findPrime ( n ) :
	num = n + 1
	while ( num ) :
		if isPrime ( num ) :
			return num
		num += 1
	return 0
def minNumber ( arr ) :
	s = 0
	for i in range ( 0 , len ( arr ) ) :
		s += arr [ i ]
	if isPrime ( s ) :
		return 0
	num = findPrime ( s )
	return num - s
arr = [ 2 , 4 , 6 , 8 , 12 ]
print ( minNumber ( arr ) )