OFFSET
1,1
COMMENTS
The geometric mean of two primes p and q is sqrt(pq).
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
EXAMPLE
The prime before 3 is 2 and the prime after 3 is 5. 2 * 5 = 10 and the geometric mean of 2 and 5 is therefore sqrt(10) = 3.16227766..., which rounds to 3. Therefore 3 is in the sequence.
The geometric mean of 7 and 13 is 9.539392... which rounds up to 10, well short of 11, hence 11 is not in the sequence.
MAPLE
A := {}: for n from 2 to 1000 do p1 := ithprime(n-1): p := ithprime(n); p2 := ithprime(n+1): if p = round(sqrt(p1*p2)) then A := `union`(A, {p}) end if end do; A := A;
MATHEMATICA
Prime[Select[Range[2, 700], Prime[#] == Round[Sqrt[Prime[# - 1] Prime[# + 1]]] &]] (* Alonso del Arte, Sep 01 2012 *)
Select[Partition[Prime[Range[750]], 3, 1], Round[GeometricMean[{#[[1]], #[[3]]}]]==#[[2]]&][[;; , 2]] (* Harvey P. Dale, Feb 28 2024 *)
PROG
(PARI) lista(nn) = forprime (p=2, nn, if (round(sqrt(precprime(p-1)*nextprime(p+1))) == p, print1(p, ", "))); \\ Michel Marcus, Apr 08 2015
(Python)
from math import isqrt
from itertools import islice
from sympy import nextprime, prevprime
def A216124_gen(startvalue=3): # generator of terms >= startvalue
q = max(3, nextprime(startvalue-1))
p = prevprime(q)
r = nextprime(q)
while True:
if q == (m:=isqrt(k:=p*r))+(k-m*(m+1)>=1):
yield q
p, q, r = q, r, nextprime(r)
CROSSREFS
KEYWORD
nonn
AUTHOR
César Eliud Lozada, Sep 01 2012
EXTENSIONS
More terms from Michel Marcus, Apr 08 2015
STATUS
approved