cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

Original entry on oeis.org

2, 4, 25, 181, 421, 3930, 8177, 102772, 199981, 3179142, 5971945, 143610511, 210826981, 4754446846, 8589934561, 222195898593, 396718580701, 13494919482970, 20479999999961, 764527028941797, 1168636602822613, 41826814261329722, 73040694872113105, 2855533828630999398
Offset: 2

Views

Author

Andrew Pope, Aug 21 2023

Keywords

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

Examples

			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.
		

Crossrefs

Programs

  • 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 *)
  • Python
    from itertools import count
    from sympy.ntheory.factor_ import digits
    def A365097(n):
        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:
                return k # Chai Wah Wu, Sep 28 2023

Formula

For even n > 2, a(n) = 2*n^(n/2) - 2*n + 1. - Jon E. Schoenfield, Sep 30 2023

Extensions

a(11)-a(15) from Amiram Eldar, Aug 29 2023
a(16)-a(19) from Chai Wah Wu, Sep 29 2023
a(20)-a(25) from Jon E. Schoenfield, Sep 30 2023