text: Count of interesting primes upto N | C # program to find the number of interesting primes up to N ; Function to check if a number is prime or not ; If n is divisible by any number between 2 and Math . Sqrt ( n ) , it is not prime ; Function to check if a number is perfect square or not ; Find floating point value of square root of x . ; If square root is an integer ; Function to find the number of interesting primes less than equal to N . ; Check whether the number is prime or not ; Iterate for values of b ; Check condition for a ; Return the required answer ; Driver code
code: using System ; using System . Collections . Generic ; class GFG { static bool isPrime ( int n ) { int flag = 1 ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { flag = 0 ; break ; } } return ( flag == 1 ? true : false ) ; } static bool isPerfectSquare ( int x ) { double sr = Math . Sqrt ( x ) ; return ( ( sr - Math . Floor ( sr ) ) == 0 ) ; } static int countInterestingPrimes ( int n ) { int answer = 0 ; for ( int i = 2 ; i <= n ; i ++ ) { if ( isPrime ( i ) ) { for ( int j = 1 ; j * j * j * j <= i ; j ++ ) { if ( isPerfectSquare ( i - j * j * j * j ) ) { answer ++ ; break ; } } } } return answer ; } public static void Main ( String [ ] args ) { int N = 10 ; Console . Write ( countInterestingPrimes ( N ) ) ; } }