human
Check if a number can be written as a sum of ' k ' prime numbers | Checking if a number is prime or not.
check for numbers from 2 to sqrt ( x ) if it is divisible return false.
Returns true if N can be written as sum of K primes.
N < 2 K directly return false.
If K = 1 return value depends on primality of N.
if N is even directly return true.
.
If N is odd , then one prime must be 2. All other primes are odd and cannot have a pair sum as even ..
If K >= 3 return true.
.
Driver function"
Solution in Python:
assistant
#Here is code to check if a number can be written as a sum of ' k ' prime numbers and the other steps required.
 def isprime ( x ) :
	i = 2
	while ( i * i <= x ) :
		if ( x % i == 0 ) :
			return 0
		i += 1
	return 1
def isSumOfKprimes ( N , K ) :
	if ( N < 2 * K ) :
		return 0
	if ( K == 1 ) :
		return isprime ( N )
	if ( K == 2 ) :
		if ( N % 2 == 0 ) :
			return 1
		return isprime ( N - 2 )
	return 1
n = 15
k = 2
if ( isSumOfKprimes ( n , k ) ) :
	print ( " Yes " )
else :
	print ( " No " )