OFFSET
1,3
COMMENTS
Alternate definition: Flattened list of all suffixes (ordered longest to shortest) of the list of all prefixes (ordered shortest to longest) of the list of positive integers. A prefix here is defined as any contiguous sublist of a list which includes the first element, and a suffix as any contiguous sublist of a list which includes the last element.
LINKS
The Nineteenth Byte Stack Exchange chat room, Message regarding this sequence. Some replies are programs to generate terms of the sequence.
FORMULA
a(n*(n^2 + 5)/6) = a(A004006(n)) = n. This is the earliest appearance of n. - Thomas Scheuerle, Sep 30 2022
EXAMPLE
1
1 2
_ 2
1 2 3
_ 2 3
_ _ 3
1 2 3 4
_ 2 3 4
_ _ 3 4
_ _ _ 4...
MATHEMATICA
Print @ Flatten @ (Reverse@FoldList[Join[#2, #]&, {#}&/@Reverse@#]& /@ FoldList[Join, Table[{n}, {n, 1, 10}]])
PROG
(JavaScript) a=n=>{for(let i=1; ++i; ){for(let j=0; ++j<i; ){for(let k=j; k<i; k++){if(!--n){return k}}}}}
(MATLAB)
function a = A356647( max_x )
a = cell2mat(arrayfun(@(x)(cell2mat(arrayfun(@(y)([y:x]), [1:x], 'UniformOutput', false))) ...
, [1:max_x], 'UniformOutput', false));
end % Thomas Scheuerle, Sep 30 2022
(Python)
from itertools import count, islice
def agen(): # generator of terms
for k in count(1):
for j in range(1, k+1):
yield from range(j, k+1)
print(list(islice(agen(), 87))) # Michael S. Branicky, Oct 11 2022
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Jonathan Kal-El Peréz, Aug 19 2022
STATUS
approved