OFFSET
1,1
EXAMPLE
The 13th lower twin prime is 179. 1+7+9=17 the lower twin prime of the twin pair (17,19).
PROG
(PARI) sdtwtwnp(n) = { local(x, y); forprime(x=1, n, y=sumdigits(twinl(x)); if(istwin(y)<0, print1(x", ") ) ) }
sumdigits(n) = { local(x, j, s=0); x=digits(n); for(j=1, length(x), s+=x[j]; ); return(s) }
digits(n) = { return(eval(Vec(Str(n)))) }
twinl(n) = { local(c, x); c=0; x=1; while(c<n, if(isprime(prime(x)+2), c++); x++; ); return(prime(x-1)) }
istwin(n) = /* Return -1 if n is a lower twin, 1 if upper, otherwise return 0 */ { local(p1, p2); if(isprime(n), p1=n-2; p2=n+2; if(isprime(p1), return(1)); if(isprime(p2), return(-1)); return(0) ) }
CROSSREFS
KEYWORD
easy,nonn,base
AUTHOR
Cino Hilliard, Mar 13 2005
STATUS
approved