Check if a number can be represented as a sum of a Prime Number and a Perfect Square

Check if a number can be represented as a sum of a Prime Number and a Perfect SquareGiven a positive integer N, the task is to check if N can be represented as a sum of a Prime Number and a Perfect Square or not. If it is possible to represent N in required form, then print “Yes”. Otherwise, print “No”.Examples:Input: N = 27Output: YesExplanation: 27 can be expressed as sum of 2 (prime) and 25 (perfect square).Input: N = 64Output: NoNaive Approach: The simplest approach to solve the given problem is to store all perfect squares which are less than or equal to N in an array. For every perfect square in the array, say X, check if (N – X) is a prime number or not. If found to be true, then print “Yes”. Otherwise, print “No”.Below is the implementation of the above approach: C++  #include using namespace std;  bool isPrime(int n){        if (n