- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

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 −

- if (x + y) is prime number and (x - y) is 1, then
- return True

- otherwise,
- return False

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))

7,6

True

- Related Questions & Answers
- Check if a prime number can be expressed as sum of two Prime Numbers in Python
- Check if N is Strong Prime in Python
- Check if N is a Factorial Prime in Python
- Check if bitwise AND of any subset is power of two in Python
- Check if product of array containing prime numbers is a perfect square in Python
- Check whether the sum of absolute difference of adjacent digits is Prime or not in Python
- Check if concatenation of two strings is balanced or not in Python
- Check if leaf traversal of two Binary Trees is same in Python
- Check whether the sum of prime elements of the array is prime or not in Python
- Check if a number is Primorial Prime or not in Python
- Check if two list of tuples are identical in Python
- Check if LCM of array elements is divisible by a prime number or not in Python
- Check if sum of divisors of two numbers are same in Python
- Python program to check if a number is Prime or not
- Is a number sum of two perfect squares in JavaScript

Advertisements