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 ; Initialize map ; Store square value in hashmap ; Driver code
using System ; using System . Collections . Generic ; class GFG { static bool prodSquare ( int n ) { Dictionary < float , float > s = new Dictionary < float , float > ( ) ; for ( int i = 2 ; i * i <= n ; ++ i ) { s . Add ( ( float ) ( i * i ) , ( float ) 1 ) ; if ( s . ContainsKey ( ( float ) n / ( i * i ) ) ) return true ; } return false ; } public static void Main ( String [ ] args ) { int n = 25 ; if ( prodSquare ( n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }