|
|
A022797
|
|
a(n) = n-th prime + n-th nonprime.
|
|
3
|
|
|
3, 7, 11, 15, 20, 23, 29, 33, 38, 45, 49, 57, 62, 65, 71, 78, 85, 88, 95, 101, 105, 112, 117, 124, 133, 139, 142, 147, 151, 157, 172, 177, 185, 188, 199, 202, 209, 217, 222, 229, 236, 239, 251, 255, 260, 263, 276, 289, 295, 298, 303, 311, 315, 326
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
LINKS
|
|
|
FORMULA
|
|
|
EXAMPLE
|
The first four primes are 2, 3, 5, 7 and the first four nonprimes are 1, 4, 6, 8. Hence a(1) = 2 + 1 = 3, a(2) = 3 + 4 = 7, a(3) = 5 + 6 = 11 and a(4) = 7 + 8 = 15.
|
|
MATHEMATICA
|
ppnp[terms_] := Module[{prs = Prime[Range[terms]], nprs, lenprs}, nprs = Complement[Range[Prime[terms]], prs]; lenprs = Length[prs]; Total /@ Thread[{prs, Take[nprs, lenprs]}]]; ppnp[60] (* Harvey P. Dale, Nov 29 2011 *)
|
|
PROG
|
(Python)
from sympy import prime, composite
def A022797(n): return 3 if n == 1 else prime(n)+composite(n-1) # Chai Wah Wu, Aug 30 2021
(PARI) a(n) = my(nonprime(i)=my(p=1, q=i); while(p!=q, p=q; q=i+primepi(p)); q); prime(n) + nonprime(n); \\ Ruud H.G. van Tol, Feb 16 2024
(PARI) alist(N) = my(r=primes(N), q=3); r[1]+=1; for(n=2, N, if(isprime(q++), q++); r[n]+=q); r; \\ Ruud H.G. van Tol, Feb 16 2024
|
|
CROSSREFS
|
Cf. A064799 (with composite numbers instead of nonprimes).
|
|
KEYWORD
|
nonn,easy,nice
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|