Practice Smallest Good Base
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given an integer n represented as a string, return the smallest good base of n. We call k >= 2 a good base of n, if all digits of n base k are 1's.
Source: Smallest Good Base on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
n = "13"
Output
"3"
# Example 2
Input
n = "4681"
Output
"8"
# Example 3
Input
n = "1000000000000000000"
Output
"999999999999999999"
Constraints
n is an integer in the range [3, 10^18].
n does not contain any leading zeros.
Related LeetCode Problems
Practice more problems similar to Smallest Good Base.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.