Check whether a number can be represented by the product of two squares | C ++ 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool 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 ; } int main ( ) { int n = 25 ; if ( prodSquare ( n ) ) cout << " Yes " ; else cout << " No " ; }