diff --git a/Check if a number can be expressed as x^y b/Check if a number can be expressed as x^y new file mode 100644 index 0000000..9bb014a --- /dev/null +++ b/Check if a number can be expressed as x^y @@ -0,0 +1,36 @@ +// { Driver Code Starts +#include +using namespace std; + + // } Driver Code Ends + + +class Solution{ +public: + int checkPower(int n){ + // code here + if(n==1){return 1;} + for(int i=2;i<=sqrt(n);i++){ + if(ceil(log(n)/log(i))==floor(log(n)/log(i))){ + // cout<>t; + while(t--) + { + int N; + cin >> N; + Solution ob; + cout << ob.checkPower(N) << endl; + } + return 0; +} // } Driver Code Ends