login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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

%I #61 Oct 01 2023 07:58:23

%S 2,4,25,181,421,3930,8177,102772,199981,3179142,5971945,143610511,

%T 210826981,4754446846,8589934561,222195898593,396718580701,

%U 13494919482970,20479999999961,764527028941797,1168636602822613,41826814261329722,73040694872113105,2855533828630999398

%N 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.

%C a(10) = A014778(3), being the smallest term > 1 there.

%C 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

%H Jon E. Schoenfield, <a href="/A365097/b365097.txt">Table of n, a(n) for n = 2..200</a>

%F For even n > 2, a(n) = 2*n^(n/2) - 2*n + 1. - _Jon E. Schoenfield_, Sep 30 2023

%e 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.

%e 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.

%e 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.

%t 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 *)

%o (Python)

%o from itertools import count

%o from sympy.ntheory.factor_ import digits

%o def A365097(n):

%o c, a, q, m = 1, 1, 0, 1

%o for k in count(2):

%o m += 1

%o if m == n:

%o m = 0

%o q += 1

%o a = digits(q,n).count(1)

%o elif m==1:

%o a += 1

%o elif m==2:

%o a -= 1

%o c += a

%o if c == k:

%o return k # _Chai Wah Wu_, Sep 28 2023

%Y Cf. A014778, A094798, A226238.

%K nonn,base

%O 2,1

%A _Andrew Pope_, Aug 21 2023

%E a(11)-a(15) from _Amiram Eldar_, Aug 29 2023

%E a(16)-a(19) from _Chai Wah Wu_, Sep 29 2023

%E a(20)-a(25) from _Jon E. Schoenfield_, Sep 30 2023

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 17 16:47 EDT 2024. Contains 375227 sequences. (Running on oeis4.)