In Google sheets How to get a list of all repdigits numbers between 0 and 10^n.
Example: We have the input n in B1 set to 3 therefore our numbers are between 0 and 10^3 alternatively between 0 and 1000
We should get this list of repdigits.
11,22,33,44,55,66,77,88,99,111,222,333,444,555,666,777,888,999
Requirments
Less references
Shortest formula
Efficient processing
If possible without lambda and its helpers
Note
If cell or row/column limit is reached is acceptable not to join the result.
More examples
n
Output
3
11,22,33,44,55,66,77,88,99,111,222,333,444,555,666,777,888,999
4
11,22,33,44,55,66,77,88,99,111,222,333,444,555,666,777,888,999,1111,2222,3333,4444,5555,6666,7777,8888,9999
5
11,22,33,44,55,66,77,88,99,111,222,333,444,555,666,777,888,999,1111,2222,3333,4444,5555,6666,7777,8888,9999,11111,22222,33333,44444,55555,66666,77777,88888,99999
6
11,22,33,44,55,66,77,88,99,111,222,333,444,555,666,777,888,999,1111,2222,3333,4444,5555,6666,7777,8888,9999,11111,22222,33333,44444,55555,66666,77777,88888,99999,111111,222222,333333,444444,555555,666666,777777,888888,999999
7
11,22,33,44,55,66,77,88,99,111,222,333,444,555,666,777,888,999,1111,2222,3333,4444,5555,6666,7777,8888,9999,11111,22222,33333,44444,55555,66666,77777,88888,99999,111111,222222,333333,444444,555555,666666,777777,888888,999999,1111111,2222222,3333333,4444444,5555555,6666666,7777777,8888888,9999999
8
11,22,33,44,55,66,77,88,99,111,222,333,444,555,666,777,888,999,1111,2222,3333,4444,5555,6666,7777,8888,9999,11111,22222,33333,44444,55555,66666,77777,88888,99999,111111,222222,333333,444444,555555,666666,777777,888888,999999,1111111,2222222,3333333,4444444,5555555,6666666,7777777,8888888,9999999,11111111,22222222,33333333,44444444,55555555,66666666,77777777,88888888,99999999
9
11,22,33,44,55,66,77,88,99,111,222,333,444,555,666,777,888,999,1111,2222,3333,4444,5555,6666,7777,8888,9999,11111,22222,33333,44444,55555,66666,77777,88888,99999,111111,222222,333333,444444,555555,666666,777777,888888,999999,1111111,2222222,3333333,4444444,5555555,6666666,7777777,8888888,9999999,11111111,22222222,33333333,44444444,55555555,66666666,77777777,88888888,99999999,111111111,222222222,333333333,444444444,555555555,666666666,777777777,888888888,999999999
10
11,22,33,44,55,66,77,88,99,111,222,333,444,555,666,777,888,999,1111,2222,3333,4444,5555,6666,7777,8888,9999,11111,22222,33333,44444,55555,66666,77777,88888,99999,111111,222222,333333,444444,555555,666666,777777,888888,999999,1111111,2222222,3333333,4444444,5555555,6666666,7777777,8888888,9999999,11111111,22222222,33333333,44444444,55555555,66666666,77777777,88888888,99999999,111111111,222222222,333333333,444444444,555555555,666666666,777777777,888888888,999999999,1111111111,2222222222,3333333333,4444444444,5555555555,6666666666,7777777777,8888888888,9999999999
11
11,22,33,44,55,66,77,88,99,111,222,333,444,555,666,777,888,999,1111,2222,3333,4444,5555,6666,7777,8888,9999,11111,22222,33333,44444,55555,66666,77777,88888,99999,111111,222222,333333,444444,555555,666666,777777,888888,999999,1111111,2222222,3333333,4444444,5555555,6666666,7777777,8888888,9999999,11111111,22222222,33333333,44444444,55555555,66666666,77777777,88888888,99999999,111111111,222222222,333333333,444444444,555555555,666666666,777777777,888888888,999999999,1111111111,2222222222,3333333333,4444444444,5555555555,6666666666,7777777777,8888888888,9999999999,11111111111,22222222222,33333333333,44444444444,55555555555,66666666666,77777777777,88888888888,99999999999
12
11,22,33,44,55,66,77,88,99,111,222,333,444,555,666,777,888,999,1111,2222,3333,4444,5555,6666,7777,8888,9999,11111,22222,33333,44444,55555,66666,77777,88888,99999,111111,222222,333333,444444,555555,666666,777777,888888,999999,1111111,2222222,3333333,4444444,5555555,6666666,7777777,8888888,9999999,11111111,22222222,33333333,44444444,55555555,66666666,77777777,88888888,99999999,111111111,222222222,333333333,444444444,555555555,666666666,777777777,888888888,999999999,1111111111,2222222222,3333333333,4444444444,5555555555,6666666666,7777777777,8888888888,9999999999,11111111111,22222222222,33333333333,44444444444,55555555555,66666666666,77777777777,88888888888,99999999999,111111111111,222222222222,333333333333,444444444444,555555555555,666666666666,777777777777,888888888888,999999999999
Repdigits are multiples of Repunits like 11, 111. We can easily create Repunits of 1 by REPeaTing 1 and supplying a SEQUENCE to number of times argument of REPT. Once created, just multiply them by sequence of 1..9 and JOIN them using ,.
Snippet(for 3):
=ARRAYFORMULA(TEXTJOIN(",",,REPT("1",SEQUENCE(3-1,1,2))*SEQUENCE(1,9)))
This question could phrased like:
How to get all repdigit, monodigit or numbers that consist of the same digit between 0 and 10^n
Use this formula
=ArrayFormula(
LAMBDA(n, REGEXEXTRACT(TEXTJOIN(",",1,BYROW(SEQUENCE(n), LAMBDA(r, TEXTJOIN(",",1,REPT(SEQUENCE(9),r))))),"11.+"))
(B1))
Explanation
We are repeating each number in the sequence {1;2;...n} 1,2,...n times and joining with comma , and join all with comma ,.
In other words:
For each number in {1;2;...n} REPT once and twice and ... n times then join all with a comma.
Used formulas help
ARRAYFORMULA - LAMBDA - REGEXEXTRACT - TEXTJOIN - BYROW - SEQUENCE - REPT
not sure how serious you are with n but try:
={""; INDEX(QUERY(FLATTEN(QUERY(TRANSPOSE(REPT(
SEQUENCE(1, 9), SEQUENCE(C1, 1, 2))&","),,9^9)),,9^9))}
where C1 = 1000 -----> (10^1000)
and if you are brave enough, change 1000 to 10000 or 50000 :)