%I #20 May 13 2024 09:15:04
%S 0,1,3,9,21,51,111,321,741,2001,4311,8931,22791,52821,112881,293061,
%T 803571,1824591,4887651,14587341,33986721,92184861,208581141,
%U 431674011,877859751,2216416971,4893531411,11363224641,24302611101,63120770481,140757089241,341317579371,742438559631,1945801500411,4352527381971,11773265516781
%N a(n) is the index of the first occurrence of n in A371091.
%C The pattern in the primorial base expansion (A049345) of the terms is constructed recursively, so that the digit-positions of the primorial base expansion are successively filled with the positive terms of this sequence (1, 3, 9, 21, ...), up to that term that still fits to the position, i.e., is less than prime(i), for the positions i >= 1 indexed from the least significant end of the expansion. The nonleading digits are "frozen", and only the most significant digit keeps on increasing from a(1) to the maximal allowed a(x) for its position, after which the next term's expansion is obtained by prepending 1 to the front. See the examples.
%H Antti Karttunen, <a href="/A372559/b372559.txt">Table of n, a(n) for n = 0..1001</a>
%H <a href="/index/Pri#primorialbase">Index entries for sequences related to primorial base</a>
%F For n >= 0, A371091(a(n)) = n, and for all k < a(n), A371091(k) < n.
%e n, a(n) in primorial base
%e 0, 0 = 0
%e 1, 1 = 1
%e 2, 3 = 11
%e 3, 9 = 111
%e 4, 21 = 311 (3 is less than prime(3)=5, so can be used now)
%e 5, 51 = 1311 (9 cannot yet be used, so append 1 to the front)
%e 6, 111 = 3311 (and then replace by next higher term that fits)
%e 7, 321 = 13311
%e 8, 741 = 33311
%e 9, 2001 = 93311 (9 is less than prime(5)=11, so can be used now)
%e 10, 4311 = 193311
%e 11, 8931 = 393311
%e 12, 22791 = 993311
%e 13, 52821 = 1993311
%e 14, 112881 = 3993311
%e 15, 293061 = 9993311
%e 16, 803571 = 19993311
%e 17, 1824591 = 39993311
%e 18, 4887651 = 99993311
%e 19, 14587341 = 199993311
%e 20, 33986721 = 399993311
%e 21, 92184861 = 999993311
%e 22, 208581141 = {21}99993311 (21 is less than prime(9)=23, so can be used now)
%e 23, 431674011 = 1{21}99993311
%e etc.
%o (PARI)
%o A002110(n) = prod(i=1,n,prime(i));
%o A235224(n) = { my(s=0, p=2); while(n, s++; n = n\p; p = nextprime(1+p)); (s); };
%o A276153(n) = { my(p=2,d=0); while(n, d = n%p; n = n\p; p = nextprime(1+p)); (d); };
%o memoA372559 = Map();
%o A372559(n) = if(n<=2, n+(n>1), my(v); if(mapisdefined(memoA372559,n,&v), v, my(prev=A372559(n-1), hi=A235224(prev), hd=A276153(prev),k=0,u); while(A372559(k)<hd, k++); u = A372559(1+k); v = if(u>=prime(hi), prev+A002110(hi), prev+((u-hd)*A002110(hi-1))); mapput(memoA372559,n,v); (v)));
%Y Positions of records in A371091.
%Y Cf. A002110, A235224, A276153.
%K nonn,base
%O 0,3
%A _Antti Karttunen_, May 11 2024
|