OFFSET
0,3
COMMENTS
The number of terms between consecutive 2's is never 4*d, since the sum of 4*d consecutive values of k is always even and consequently a(n+4*d) is even (not a prime).
LINKS
Aaron Pieniozek, Table of n, a(n) for n = 0..199
EXAMPLE
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
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
]
CROSSREFS
KEYWORD
nonn
AUTHOR
Aaron Pieniozek, May 01 2025
STATUS
approved
