Suppose we have a prime number n. we have to check whether we can express n as x + y where x and y are also two prime numbers.
So, if the input is like n = 19, then the output will be True as we can express it like 19 = 17 + 2
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
from math import sqrt def isPrime(number): if number <= 1: return False if number == 2: return True if number % 2 == 0: return False for i in range(3, int(sqrt(number))+1, 2): if number%i == 0: return False return True def solve(number): if isPrime(number) and isPrime(number - 2): return True else: return False n = 19 print(solve(n))