Find the longest rep digit Your task is to take a positive number as input, n, and output the length of the longest rep-digit representation of n in any base. For example 7 can be represented as any of the following

111_2
21_3
13_4
12_5
11_6
10_7
7_8


The rep-digits are 111_2 and 11_6, 111_2 is longer so our answer is 3.

This is a code-golf question so answers will be scored in bytes, with fewer bytes being better.

Test Cases

1   -&gt; 1
2   -&gt; 1
3   -&gt; 2
4   -&gt; 2
5   -&gt; 2
6   -&gt; 2
7   -&gt; 3
8   -&gt; 2
9   -&gt; 2
10  -&gt; 2
11  -&gt; 2
26 -&gt; 3
63  -&gt; 6
1023-&gt; 10


Sample implementation

Here is an implementation in Haskell that can be used to generate more test cases.



f 0 y=[]
f x y=f(div x y)y++[mod x y]
s x=all(==x!!0)x
g x=maximum$map(length.f x)$filter(s.f x)[2..x+1]


Try it online!
Jelly, 9 bytes

b‘Ḋ$EÐfZL


A monadic link accepting and returning numbers

Try it online! or see a test suite (inputs one to 32 inclusive).

How?

b‘Ḋ$EÐfZL - Link: number, n
   $      - last two links as a monad:
 ‘        -   increment = n+1
  Ḋ       -   dequeue (with implicit range build) = [2,3,4,...,n+1]
b         - convert to those bases
     Ðf   - filter keep if:
    E     -   all elements are equal
       Z  - transpose
        L - length (note:  length of the transpose of a list of lists is the length of the
          -                longest item in the original list, but shorter than L€Ṁ)




...or maybe I should have done:

bḊEÐfZLo1


For the Lo1z.