From 007e5106c07524a29ca23a446b532d232d212087 Mon Sep 17 00:00:00 2001 From: Udhay <72250606+Udhay-Brahmi@users.noreply.github.com> Date: Thu, 10 Dec 2020 08:39:15 +0530 Subject: [PATCH] Create Check if a number can be expressed as x^y --- Check if a number can be expressed as x^y | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Check if a number can be expressed as x^y 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