login
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).
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,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
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
Sequence in context: A075410 A023513 A069735 * A358536 A274457 A328579
KEYWORD
nonn
AUTHOR
Aaron Pieniozek, May 01 2025
STATUS
approved