|
|
A365097
|
|
Smallest k > 1 such that the total number of digits "1" required to write the numbers 1..k in base n is equal to k.
|
|
1
|
|
|
2, 4, 25, 181, 421, 3930, 8177, 102772, 199981, 3179142, 5971945, 143610511, 210826981, 4754446846, 8589934561, 222195898593, 396718580701, 13494919482970, 20479999999961, 764527028941797, 1168636602822613, 41826814261329722, 73040694872113105, 2855533828630999398
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
2,1
|
|
COMMENTS
|
a(10) = A014778(3), being the smallest term > 1 there.
An upper bound is a(n) <= A226238(n) = u, since the digits of u show there are u 1's in numbers 1..u (in base n). - Kevin Ryde, Sep 28 2023
|
|
LINKS
|
|
|
FORMULA
|
|
|
EXAMPLE
|
For n=2, the first k=2 positive integers are 1 = 1_2 and 2 = 10_2, which have a total of two 1's, so a(2) = 2.
For n=3, the first k=4 positive integers, which are 1_3, 2_3, 10_3, and 11_3, have a total of four 1's, which is equal to k, so a(3) = 4.
For n=4, a total of 25 1's occur in the first k=25 positive integers (they occur in 1_4, 10_4, 11_4, 12_4, 13_4, 21_4, 31_4, 100_4, 101_4, 102_4, 103_4, 110_4, 111_4, 112_4, 113_4, 120_4, and 121_4 = 25), so a(4) = 25.
|
|
MATHEMATICA
|
a[n_] := Module[{k = 1, sum = 1}, While[sum == 1 || sum != k, k++; sum += Count[IntegerDigits[k, n], 1]]; k]; Array[a, 6, 2] (* Amiram Eldar, Aug 29 2023 *)
|
|
PROG
|
(Python)
from itertools import count
from sympy.ntheory.factor_ import digits
c, a, q, m = 1, 1, 0, 1
for k in count(2):
m += 1
if m == n:
m = 0
q += 1
a = digits(q, n).count(1)
elif m==1:
a += 1
elif m==2:
a -= 1
c += a
if c == k:
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|