cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A022797 a(n) = n-th prime + n-th nonprime.

Original entry on oeis.org

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
Offset: 1

Views

Author

Keywords

Examples

			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.
		

Crossrefs

Cf. A064799 (with composite numbers instead of nonprimes).

Programs

  • 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 *)
  • 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
  • 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
    

Formula

a(n) = A000040(n) + A018252(n). - Jaroslav Krizek, Nov 18 2009