text: Euler 's criterion (Check if square root under modulo p exists) | Returns true if square root of n under modulo p exists ; One by one check all numbers from 2 to p - 1 ; Driver Code
code: < ? php function squareRootExists ( $ n , $ p ) { $ n = $ n % $ p ; for ( $ x = 2 ; $ x < $ p ; $ x ++ ) if ( ( $ x * $ x ) % $ p == $ n ) return true ; return false ; } $ p = 7 ; $ n = 2 ; if ( squareRootExists ( $ n , $ p ) == true ) echo " Yes " ; else echo " No " ; ? >