A383594 a(0) = 0 and thereafter a(n) = 2 if a(n-1) is an odd prime, otherwise a(n) = a(n-1) + k where k = n - P(n) and P(n) is the number of odd primes among terms a(0),...,a(n-1).
0, 1, 3, 2, 5, 2, 6, 11, 2, 8, 15, 23, 2, 11, 2, 12, 23, 2, 14, 27, 41, 2, 17, 2, 18, 35, 53, 2, 21, 41, 2, 23, 2, 24, 47, 2, 26, 51, 77, 104, 132, 161, 191, 2, 33, 65, 98, 132, 167, 2, 38, 75, 113, 2, 41, 2, 42, 83, 2, 44, 87, 131, 2, 47, 2, 48, 95, 143, 192, 242
Offset: 0
Keywords
Examples
The sequence, and the k increments applied, begin a(n) = 0, 1, 3, 2, 5, 2, 6, 11, 2, 8, 15, 23, ... k = 1 2 3 4 5 6 7 8
Links
- Aaron Pieniozek, Table of n, a(n) for n = 0..199
Programs
-
Maple
seq := proc(n) local a, i, k; a := [0]; k := 1; for i from 1 to n-1 do if isprime(a[-1]) and a[-1] <> 2 then a := [op(a), 2]; else a := [op(a), a[-1] + k]; k := k + 1; end if; end do; return a; end proc:
-
Mathematica
sequence[n_] := Module[{a = {0}, k = 1}, While[Length[a] < n, If[PrimeQ[Last[a]] && Last[a] != 2, AppendTo[a, 2], AppendTo[a, Last[a] + k]; k++ ]; ]; a ]
Comments