login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A349792 Numbers k such that k*(k+1) is the median of the primes between k^2 and (k+1)^2. 2

%I #37 Dec 13 2021 15:18:56

%S 2,3,5,6,8,25,29,38,59,101,135,217,260,295,317,455,551,686,687,720,

%T 825,912,1193,1233,1300,1879,1967,2200,2576,2719,2857,3303,3512,4215,

%U 4241,4448,4658,5825,5932,5952,6155,6750,7275,10305,10323,10962,11279,13495,14104

%N Numbers k such that k*(k+1) is the median of the primes between k^2 and (k+1)^2.

%H Chai Wah Wu, <a href="/A349792/b349792.txt">Table of n, a(n) for n = 1..552</a> (terms 1..85 from Hugo Pfoertner)

%t Select[Range@3000,Median@Select[Range[#^2,(#+1)^2],PrimeQ]==#(#+1)&] (* _Giorgos Kalogeropoulos_, Dec 05 2021 *)

%o (PARI) a349791(n) = {my(p1=nextprime(n^2), p2=precprime((n+1)^2), np1=primepi(p1), np2=primepi(p2), nm=(np1+np2)/2); if(denominator(nm)==1, prime(nm), (prime(nm-1/2)+prime(nm+1/2))/2)};

%o for(k=2,5000, my(t=k*(k+1)); if(t==a349791(k),print1(k,", ")))

%o (Python)

%o from sympy import primerange

%o from statistics import median

%o def ok(n): return n>1 and int(median(primerange(n**2, (n+1)**2)))==n*(n+1)

%o print([k for k in range(999) if ok(k)]) # _Michael S. Branicky_, Dec 05 2021

%o (Python)

%o from itertools import count, islice

%o from sympy import primepi, prime, nextprime

%o def A349792gen(): # generator of terms

%o p1 = 0

%o for n in count(1):

%o p2 = primepi((n+1)**2)

%o b = p1 + p2 + 1

%o if b % 2:

%o p = prime(b//2)

%o q = nextprime(p)

%o if p+q == 2*n*(n+1):

%o yield n

%o p1 = p2

%o A349792_list = list(islice(A349792gen(),12)) # _Chai Wah Wu_, Dec 08 2021

%Y Cf. A000290, A000720, A002378, A014085, A349791.

%K nonn

%O 1,1

%A _Hugo Pfoertner_, Dec 05 2021

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 19 19:39 EDT 2024. Contains 374436 sequences. (Running on oeis4.)