OFFSET
1,2
COMMENTS
The sequence was inspired by A365339.
LINKS
Peter Luschny, Table of n, a(n) for n = 1..10000
Plot2, A365399 vs A365339.
FORMULA
a(n+1) - a(n) <= 1.
EXAMPLE
The terms of the subsequences of A000005 are marked by '*'. They start:
1*, 2, 2 , 3, 2, 4, 2, 4, ... -> a(1) = 1
1*, 2*, 2 , 3, 2, 4, 2, 4, ... -> a(2) = 2
1*, 2*, 2*, 3, 2, 4, 2, 4, ... -> a(3) = 3
1*, 2*, 2*, 3*, 2, 4, 2, 4, ... -> a(4) = 4
1*, 2*, 2*, 3*, 2, 4, 2, 4, ... -> a(5) = 4
1*, 2*, 2*, 3*, 2, 4*, 2, 4, ... -> a(6) = 5
1*, 2*, 2*, 3*, 2, 4*, 2, 4, ... -> a(7) = 5
1*, 2*, 2*, 3*, 2, 4*, 2, 4*, ... -> a(8) = 6
Example: a(2000000) = 450033.
PROG
(Julia)
# Computes the first N terms of the sequence using function tau from A000005.
function LLS_list(seq, N)
lst = zeros(Int64, N)
dyn = zeros(Int64, N)
for n in 1:N
p = seq(n)
nxt = dyn[p] + 1
while p <= N && dyn[p] < nxt
dyn[p] = nxt
p += 1
end
lst[n] = dyn[n]
end
return lst
end
A365399List(N) = LLS_list(tau, N)
println(A365399List(69))
(Python)
from bisect import bisect
from sympy import divisor_count
def A365399(n):
plist, qlist, c = tuple(divisor_count(i) for i in range(1, n+1)), [0]*(n+1), 0
for i in range(n):
qlist[a:=bisect(qlist, plist[i], lo=1, hi=c+1, key=lambda x:plist[x])]=i
c = max(c, a)
return c # Chai Wah Wu, Sep 04 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Peter Luschny, Sep 03 2023
STATUS
approved