login
A363707
For n >= 2, a(n) = a(n-1) + a(n-2) + A051697(n), a(0)=0, a(1)=1.
0
0, 1, 3, 7, 13, 25, 43, 75, 125, 207, 343, 561, 915, 1489, 2417, 3919, 6353, 10289, 16659, 26967, 43645, 70631, 114299, 184953, 299275, 484251, 783549, 1267829, 2051407, 3319265, 5370701, 8689997, 14060729, 22750757, 36811517, 59562311, 96373865, 155936213, 252310115
OFFSET
0,3
FORMULA
a(0)=0, a(1)=1, a(n) = a(n-1) + a(n-2) + p(n), where p(n) = min{p:p is prime and |p-n| is minimized, and the smaller prime when n is equidistant between primes}.
EXAMPLE
a(2) = 3 since a(1) + a(0) = 1 and p(2) = 2. Furthermore a(3) = 3 + 1 + p(3) = 7.
MATHEMATICA
p[n_] := (np = NextPrime[n]; pp = Prime[PrimePi[np] - 1];
Which[np > 2 n - pp, pp, np < 2 n - pp, np, True, pp]); (* Using the already existing code from A051697 *)
sequenceLength = 50; (* Specify the desired length of the sequence *)
sequence = {0, 1}; (* Initialize the sequence with the first two terms *)
For[n = 2, n < sequenceLength, n++,
nextTerm = sequence[[-2]] + sequence[[-1]] + p[n];
sequence = Append[sequence, nextTerm]]
Print[sequence]
CROSSREFS
Cf. A051697.
Sequence in context: A092463 A259343 A210613 * A304648 A243737 A269832
KEYWORD
nonn
AUTHOR
Yanick Willert, Jun 16 2023
STATUS
approved