Surd number | Java program to find if a number is Surds or not ; Returns true if x is Surd number ; Try all powers of i ; Driver Code
class GFG { static boolean isSurd ( int n ) { for ( int i = 2 ; i * i <= n ; i ++ ) { int j = i ; while ( j < n ) j = j * i ; if ( j == n ) return false ; } return true ; } public static void main ( String args [ ] ) { int n = 15 ; if ( isSurd ( n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }