Surd number | CPP program to find if a number is Surds or not ; Returns true if x is Surd number ; Try all powers of i ; driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool 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 ; } int main ( ) { int n = 15 ; if ( isSurd ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }