login
A235649
Define a(4)=3 then a(n+1)is the smallest prime P such that a(n)<=P< n with 2*n-P=Q prime and if not possible a(n+1) is the smallest prime P such that P<a(n)<n with 2*n-P=Q prime
2
3, 3, 5, 3, 3, 5, 7, 3, 5, 7, 11, 11, 13, 3, 5, 7, 11, 11, 13, 17, 17, 19, 23, 23, 3, 5, 7, 19, 23, 23, 31, 3, 5, 7, 17, 17, 19, 23, 23, 3, 5, 7, 13, 23, 23, 31, 41, 41, 43, 47, 47, 3, 3, 5, 7, 11, 11, 13, 17, 17, 19, 23, 23, 31, 47, 59, 61, 3, 5, 7, 11
OFFSET
4,1
EXAMPLE
a(4)=3 as 2*4-3=5 prime by definition
a(5)=3 as 2*5-3=7 prime, a(5)=a(4), a(5)<5
a(6)=5 as 2*6-5=7 prime, a(6)>a(5), a(6)<6
a(7)=5 not possible as 14-5=9 composite
a(7)=7 not possible as 7=7
a(7)=3 as 2*7-3=11 prime
a(8)=3 as 2*8-3=13 prime
PROG
(PFGW & SCRIPT)
SCRIPT
DIM n, 3
DIM i
DIM pp
DIMS t
OPENFILEOUT myf, a(n).txt
LABEL loop1
OPENFILEIN maf, prime.txt
GETNEXT i, maf
GETNEXT i, maf
LABEL a
SET n, n+1
IF n>10005 THEN END
SET pp, 2*n-i
SETS t, %d, %d\,; n; i
PRP pp, t
IF ISPRP THEN GOTO c
LABEL b
GETNEXT i, maf
IF n-i<3 THEN GOTO d
SET pp, 2*n-i
SETS t, %d, %d\,; n; i
PRP pp, t
IF ISPRP THEN GOTO c
GOTO b
LABEL c
WRITE myf, t
GOTO a
LABEL d
CLOSEFILE maf
SET n, n-1
GOTO loop1
CROSSREFS
KEYWORD
nonn
AUTHOR
Pierre CAMI, Jan 13 2014
STATUS
approved