Suppose we have a pair of integers. We have to check whether they are cousin primes or not. Two numbers are said to be cousin primes when both are primes and differ by 4.
So, if the input is like pair = (19,23), then the output will be True as these are two primes and their difference is 4 so they are cousin primes.
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
def isPrime(num): if num > 1: for i in range(2, num): if num % i == 0: return False return True return False def solve(pair) : if not abs(pair-pair)== 4: return False return isPrime(pair) and isPrime(pair) pair = (19,23) print(solve(pair))