Check whether a number can be represented by the product of two squares | Java implementation to check whether a number can be represented by the product of two squares ; Function to check if there exist two numbers product of whose squares is n . ; Check whether the product of the square of both numbers is equal to N ; Driver code
class GFG { static boolean prodSquare ( int n ) { for ( long i = 2 ; i * i <= n ; i ++ ) for ( long j = 2 ; j <= n ; j ++ ) if ( i * i * j * j == n ) return true ; return false ; } public static void main ( String [ ] args ) { int n = 25 ; if ( prodSquare ( n ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }