Leaderboard
Showing:
Base Equivalence
Easy Accuracy: 41.85% Submissions: 137 Points: 2

Given a number (n) and no. of digits (m) to represent the number, find if given number can be represented in given no. of digits in any base from 2 to 32.

Example 1:

Input: n = 8, m = 2
Output: Yes 
Explanation: Possible in base 3 as 8 in base 3 is 22.  


Example 2:

Input: n = 8, m = 3
Output: No
Explanation: Not possible in any base. 


Your Task:  
You dont need to read input or print anything. Complete the function baseEquiv() which takes n and m as input parameter and returns "Yes" if its possible to represent the number else "No" without quotes..

Expected Time Complexity: O(logN).
Expected Auxiliary Space: O(1)

Constraints:
1 <= n <=109
1 <= m <=32

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.

Base Equivalence

Output Window