login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A338467
a(n+1) = prime(n) + 2*n - a(n). a(1) = 1.
0
1, 3, 4, 7, 8, 13, 12, 19, 16, 25, 24, 29, 32, 35, 36, 41, 44, 49, 48, 57, 54, 61, 62, 67, 70, 77, 76, 81, 82, 85, 88, 101, 94, 109, 98, 121, 102, 129, 110, 135, 118, 143, 122, 155, 126, 161, 130, 175, 144, 181, 148, 187, 156, 191, 168, 199, 176, 207, 180, 215
OFFSET
1,2
FORMULA
a(n+1) = A078916(n) - a(n). - Michel Marcus, Jan 31 2021
EXAMPLE
a(1) + a(2) - 2*1 = 1st prime; 1 + 3 - 2*1 = 2.
a(13) + a(14) - 2*13 = 13th prime; 32 + 35 - 2*13 = 41.
MAPLE
a:= proc(n) option remember; `if`(n=1, 1,
ithprime(n-1)-a(n-1)+2*n-2)
end:
seq(a(n), n=1..60); # Alois P. Heinz, Jan 31 2021
MATHEMATICA
a[1] = 1; a[n_] := a[n] = Prime[n - 1] + 2*(n - 1) - a[n - 1]; Array[a, 60] (* Amiram Eldar, Feb 01 2021 *)
PROG
(Python)
from sympy import prime
S=[1]
nomb=100
for n in range(1, nomb):
derterm=S[-1]
terme= prime(n)-derterm+2*(len(S))
S.append(terme)
print(S)
(PARI) a(n) = if (n==1, 1, prime(n-1) + 2*(n-1) - a(n-1)); \\ Michel Marcus, Jan 31 2021
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Carole Dubois, Jan 31 2021
STATUS
approved