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.

A178670 Number of ways to express prime(n) as (prime(n+k) + prime(n-k))/2.

Original entry on oeis.org

0, 0, 1, 0, 2, 1, 1, 0, 0, 2, 1, 1, 2, 0, 0, 2, 1, 1, 1, 3, 0, 0, 1, 1, 2, 1, 1, 1, 0, 0, 2, 2, 2, 1, 0, 1, 3, 0, 1, 3, 2, 1, 4, 2, 1, 0, 4, 0, 0, 0, 2, 0, 0, 2, 1, 1, 0, 0, 1, 0, 0, 0, 3, 4, 0, 0, 1, 1, 1, 2, 3, 3, 2, 4, 2, 2, 1, 3, 4, 4, 1, 1, 1, 3, 2, 2, 2, 1, 1, 0, 0, 1, 2, 1, 0, 0, 0, 3, 0, 2
Offset: 1

Views

Author

Juri-Stepan Gerasimov, Jan 04 2011

Keywords

Examples

			a(5) = 2 because the 5th prime (11) is half the sum of the 7th and 3rd prime (17+5) or half the sum of the 8th and 2nd prime (19+3).
a(8) = 0 because the 8th prime (19) cannot be expressed as (1/2)*(prime(8+k) + prime(8-k)) for any k.
		

Crossrefs

Programs

  • Mathematica
    nn=1000; p=Prime[Range[2*nn]]; Table[s=Take[p,n-1] + Reverse[Take[p, {n+1,2n-1}]]; Count[s,2*p[[n]]], {n,nn}]
  • PARI
    a(n)={s=2*prime(n);a=0;for(i=1,n-1,if(prime(n+i)+prime(n-i)==s,a=a+1));a}