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.
%I A216124 #28 Jun 19 2024 15:07:30 %S A216124 3,5,7,23,53,157,173,211,257,263,373,563,593,607,653,733,947,977,1103, %T A216124 1123,1187,1223,1367,1511,1747,1753,1907,2287,2417,2677,2903,2963, %U A216124 3307,3313,3637,3733,4013,4409,4457,4597,4657,4691,4993,5107,5113,5303,5387,5393 %N A216124 Primes which are the nearest integer to the geometric mean of the previous prime and the following prime. %C A216124 The geometric mean of two primes p and q is sqrt(pq). %H A216124 Harvey P. Dale, <a href="/A216124/b216124.txt">Table of n, a(n) for n = 1..1000</a> %e A216124 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. %e A216124 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. %p A216124 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; %t A216124 Prime[Select[Range[2, 700], Prime[#] == Round[Sqrt[Prime[# - 1] Prime[# + 1]]] &]] (* _Alonso del Arte_, Sep 01 2012 *) %t A216124 Select[Partition[Prime[Range[750]],3,1],Round[GeometricMean[{#[[1]],#[[3]]}]]==#[[2]]&][[;;,2]] (* _Harvey P. Dale_, Feb 28 2024 *) %o A216124 (PARI) lista(nn) = forprime (p=2, nn, if (round(sqrt(precprime(p-1)*nextprime(p+1))) == p, print1(p, ", "))); \\ _Michel Marcus_, Apr 08 2015 %o A216124 (Python) %o A216124 from math import isqrt %o A216124 from itertools import islice %o A216124 from sympy import nextprime, prevprime %o A216124 def A216124_gen(startvalue=3): # generator of terms >= startvalue %o A216124 q = max(3,nextprime(startvalue-1)) %o A216124 p = prevprime(q) %o A216124 r = nextprime(q) %o A216124 while True: %o A216124 if q == (m:=isqrt(k:=p*r))+(k-m*(m+1)>=1): %o A216124 yield q %o A216124 p, q, r = q, r, nextprime(r) %o A216124 A216124_list = list(islice(A216124_gen(),20)) # _Chai Wah Wu_, Jun 19 2024 %Y A216124 Cf. A216101, A090076. %K A216124 nonn %O A216124 1,1 %A A216124 _César Eliud Lozada_, Sep 01 2012 %E A216124 More terms from _Michel Marcus_, Apr 08 2015