Smallest Good Base

Given an integer A, we call k >= 2 a good base of A, if all digits of A base k are 1.
Now given a string representing A, you should return the smallest good base of A in string format.



Input Format

The only argument given is the string representing A.

Output Format

Return the smallest good base of A in string format.

Constraints

3 <= A <= 10^18

For Example

Input 1:
    A = "13"
Output 1:
    "3"     (13 in base 3 is 111)

Input 2:
    A = "4681"
Output 2:
    "8"     (4681 in base 8 is 11111).
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Smallest Good Base on Interview Code Editor
Sign Up
to access hints and editorial solutions for Smallest Good Base

Discussion


Loading...
Click here to start solving coding interview questions