A327246 a(1) = 0; build a(n+1) by concatenating 2 strings: first, the number of digits of a(n), second, the number of terms with same number of digits as a(n) up to a(n).
0, 11, 21, 22, 23, 24, 25, 26, 27, 28, 29, 210, 31, 211, 32, 212, 33, 213, 34, 214, 35, 215, 36, 216, 37, 217, 38, 218, 39, 219, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335
Offset: 1
Examples
a(1) = 0. a(2) = 11 since 0 is the first instance of a 1-digit number in the sequence, a(3) = 21 since 11 is the first instance of a 2-digit number, a(4) = 22 since 21 is the second instance of a 2-digit number, ... a(12) = 210 since 29 is the tenth instance of a 2-digit number, a(13) = 31 since 210 is the first instance of a 3-digit number, etc. a(1) can be any positive integer number between 0-9, the sequence will not have further change. The overall sequence is defined by the number of digits of a(1). For example if a(1) were 1000000000 or 9999999999, then we would have a(2)=101, a(3)=31, a(4)=21, a(5)=22, ... where a(1) has 10 digits so a(2) would start with 10 and ends with 1, etc.
Links
- Michael De Vlieger, Table of n, a(n) for n = 1..10000
- Michael De Vlieger, Log log scatterplot of a(n) for n = 1..2^20.
Programs
-
MATLAB
length_of_sequence=2000; sequence=zeros(1,length_of_sequence); %allocation for the sequence sequence(1)=11; %start from a(2)=11 for i=1:1:(length_of_sequence-1) first=numel(num2str(sequence(1,i))); %defining the first string second=0; for index = 1:size(sequence, 2) if numel(num2str(sequence(index)))==first second=second+1; %defining the second string end end s = strcat(num2str(first),num2str(second));%building a(n+1) sequence(i+1)=str2double(s); %placing the value into a(n+1) end result_sequence=transpose(sequence);
-
Mathematica
iL[n_] := IntegerLength[n] + Boole[n==0]; a[1]=0; a[n_] := a[n] = Block[{t = iL@ a[n-1]}, FromDigits[ Join @@ IntegerDigits@ {t, Count[iL /@ Array[a, n - 1], t]}]]; Array[a, 56] (* Giovanni Resta, Sep 16 2019 *) (* Fast program memoizing the number of instances of a given integer length: *) c[] = j = 0; c[0] = 1; {0}~Join~Reap[Do[(c[#]++; Set[k, #*10^IntegerLength[c[#]] + c[#]]) &[Boole[j == 0] + IntegerLength[j]]; Sow[k]; j = k, {i, 10^4}]][[-1, -1]] (* _Michael De Vlieger, Dec 23 2021 *)
-
PARI
lista(nn) = {my(va = vector(nn)); va[1] = 0; for (n=2, nn, my(nba = #Str(va[n-1])); my(vn = vector(n-1, k, va[k])); my(nbb = #select(x->(#Str(x)==nba), vn)); va[n] = eval(concat(Str(nba), Str(nbb)));); va;} \\ Michel Marcus, Sep 16 2019
-
Python
from itertools import islice from collections import Counter def agen(): # generator of terms an, c = 0, Counter() while True: yield an d = len(str(an)) c[d] += 1 an = int(str(d) + str(c[d])) print(list(islice(agen(), 60))) # Michael S. Branicky, Nov 12 2022
Comments