Suppose we have two numbers x and y. We have to check whether difference of their areas is prime or not.
So, if the input is like x = 7, y = 6, then the output will be True as the difference of their square is 49 - 36 = 13 which is prime.
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
def is_prime(num) : if num <= 1 : return False if num <= 3 : return True if num % 2 == 0 or num % 3 == 0 : return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i = i + 6 return True def solve(x, y): if is_prime(x + y) and x - y == 1: return True else: return False x, y = 7, 6 print(solve(x, y))