login
a(n) = smallest number > a(n-1) such that the number of preceding terms in the sequence dividing a(n) is divisible by 4; a(1) = 2.
0

%I #35 Mar 08 2018 03:12:27

%S 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,

%T 97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,

%U 181,191,193,197,199,210,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,330,331

%N a(n) = smallest number > a(n-1) such that the number of preceding terms in the sequence dividing a(n) is divisible by 4; a(1) = 2.

%C First differs from A000040 at a(47)=210.

%e 3 is in the sequence because no preceding terms (i.e., 0 terms) divide it and 0 is divisible by 4.

%e 4 is not in the sequence because there is only 1 term (i.e., a(1) = 2) that divides it and 1 is not divisible by 4.

%t With[{k = 4}, Nest[Append[#, SelectFirst[Range[#[[-1]] + 1, #[[-1]] + 120], Function[n, Divisible[Count[#, _?(Divisible[n, #] &)], k]]]] &, {2}, 68]] (* _Michael De Vlieger_, Feb 15 2018 *)

%o (Python)

%o import math

%o def getSeq(n):

%o ....if n == 1:

%o ........return [2]

%o ....prev = getSeq(n-1)

%o ....cand = max(prev)

%o ....while True:

%o ........cand += 1

%o ........if len( [n for n in prev if cand % n == 0] ) % 4 == 0:

%o ............prev.append(cand)

%o ............return prev

%o print(getSeq(100))

%o (PARI) isok(k, va, nb) = (sum(j=1, nb, !(k % va[j])) % 4) == 0;

%o lista(nn) = {va = vector(nn); va[1] = 2; for (n=2, nn, k = va[n-1]+1; while (! isok(k, va, n-1), k++); va[n] = k;); va;} \\ _Michel Marcus_, Mar 01 2018

%Y Subsequence of A005117.

%Y Cf. A000040, A030059.

%K nonn,easy

%O 1,1

%A _Masahiko Shin_, Feb 12 2018