A305748 Distance of a prime number from the average of the next two consecutive prime numbers.
2, 3, 4, 5, 4, 5, 4, 7, 7, 5, 8, 5, 4, 7, 9, 7, 5, 8, 5, 5, 8, 7, 10, 10, 5, 4, 5, 4, 11, 16, 7, 7, 7, 11, 5, 9, 8, 7, 9, 7, 7, 11, 4, 5, 8, 18, 14, 5, 4, 7, 7, 7, 13, 9, 9, 7, 5, 8, 5, 7, 17, 16, 5, 4, 11, 17, 11, 11, 4, 7, 10, 11, 9, 8, 7, 10, 10, 8, 13, 11, 7, 11, 5, 8, 7, 10, 10, 5, 4, 10, 16, 10, 8, 10, 7, 12, 13
Offset: 1
Examples
For n=4 prime(4) = 7. The next two primes are 11, 13 and the average (11 + 13) / 2 = 12. So 12 - 7 = 5 and a(4) = 5.
Programs
-
Mathematica
Map[Mean@ Rest@ # - First@ # &, Partition[Prime@ Range@ 99, 3, 1]] (* Michael De Vlieger, Jun 11 2018 *)
-
PARI
{ forprime(n = 2, 100, p1 = nextprime(n+1); p2 = nextprime(p1 + 1); print1((p1 + p2) / 2 - n", ")) }