A338812 Smaller term of a pair of sexy primes (A023201) such that the distance to next pair (A227346) is a square.
7, 13, 37, 97, 103, 223, 307, 331, 457, 541, 571, 853, 877, 1087, 1297, 1423, 1483, 1621, 1867, 1993, 2683, 3457, 3511, 3691, 3761, 3847, 4513, 4657, 4783, 4951, 5227, 5521, 5647, 5861, 6337, 6547, 6823, 7481, 7541, 7681, 7717, 7753, 7873, 8287, 8521, 8887, 9007, 9397, 10267, 10453
Offset: 1
Examples
a(2)=13 is in the sequence because the two consecutive sexy prime pairs being (13,19) and (17,23),the distance between them is 17-13=4 which is a square (2^2). 73 is not in the sequence because the two consecutive sexy prime pairs being (73,79) and (83,89),the distance between them is 83-73=10 which is not a square.
Links
- Robert Israel, Table of n, a(n) for n = 1..10000
Programs
-
Maple
count:= 0: sp:= 5: R:= NULL: p:= sp; while count < 100 do p:= nextprime(p); if isprime(p+6) then d:= p - sp; if issqr(d) then count:= count+1; R:= R, sp; fi; sp:= p; fi; od: R; # Robert Israel, May 08 2024
-
PARI
lista(nn) = {my(vs = select(x->(isprime(x) && isprime(x+6)), [1..nn]), vd = vector(#vs-1, k, vs[k+1] - vs[k]), vk = select(issquare, vd, 1)); vector(#vk, k, vs[vk[k]]);} \\ Michel Marcus, Nov 14 2020
-
R
primes<-generate_n_primes(7000000) Matrix_1<-matrix(c(primes),nrow=7000000,ncol=1,byrow=TRUE) p1<-c(0) p2<-c(0) k<-c(0) distance<-c(0) distance_square<-(0) Matrix_2<-cbind(Matrix_1,p1,p2,k,distance,distance_square) counter=0 j=1 while(j<= 7000000){ p<-(Matrix_2[j,1])+6 if(is_prime(p)){ counter=counter+1 Matrix_2[counter,2]<-(p-6) Matrix_2[counter,3]<-p } j=j+1 } a_n<-c() k=1 while(k<=1000000){ Matrix_2[k,4]<-k dist<-Matrix_2[k+1,2]-Matrix_2[k,2] Matrix_2[k,5]<-dist if(sqrt(dist)%%1==0){ Matrix_2[k,6]<-dist a_n<-append(a_n,Matrix_2[k,2]) } k=k+1 } View(Matrix_2) View(a_n)
Comments