Check if a number can be expressed as x^y
Basic Accuracy: 29.63% Submissions: 54 Points: 1

Given a positive integer N, find if it can be expressed as xy where y > 1 and x > 0 and x and y both are both integers.

 

Example 1:

Input:
N = 8
Output:
1
Explanation:
8 can be expressed
as 23.

 

 

Example 2:

Input:
N = 7
Output:
0
Explanation:
7 can't be expressed
int the form xy.

 

 

Your Task:

You don't need to read input or print anything. Your task is to complete the function checkPower() which takes an integer N and returns 1 if possible else, 0.

 

Expected Time Complexity: O(sqrt(N))
Expected Auxiliary Space: O(1)

 


Constraints:
1<= N <=10000


 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.