OFFSET
1,2
LINKS
Peter J. C. Moses, Table of n, a(n) for n = 1..10000
FORMULA
a(p) = 2, where p is prime, other than 3 and 5.
EXAMPLE
1-3) a(1)=1, a(2)=2 a(3)=4 by the definition;
4) Let n=4. From the previous terms {1,2,4} everyone divides 4, so a(4)=3;
5) Let n=5. From the previous terms {1,2,4,3} only 1 divides 5. So a(5)=1;
6) Let n=6. From the previous terms {1,2,4,3,1} exactly four divide 6. So a(6)=4; etc.
MATHEMATICA
first[n_] := Fold[Append[#1, Count[#1, k_ /; Divisible[#2, k]]] &,
2^Range[0, Min[n - 1, 2]], Range[4, n]] (* Michael De Vlieger, Dec 23 2017 *)
PROG
(PARI) first(n) = my(res = vector(n), c = 0); for(x = 1, min(n, 3), res[x] = 1<<(x-1)); for(x=4, n, for(k=1, x-1, if(x%res[k]==0, c++)); res[x] = c; c = 0); res \\ Iain Fox, Dec 23 2017
(Sage)
def A297003_list(leng):
L = [1, 2, 4]
if leng < 4: return L[0:leng]
for n in (4..leng) :
count = 0
for l in L: count += int(l.divides(n))
L.append(count)
return L
print(A297003_list(76)) # Peter Luschny, Dec 24 2017
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Vladimir Shevelev, Dec 23 2017
EXTENSIONS
More terms from Peter J. C. Moses, Dec 23 2017
STATUS
approved