OFFSET
1,1
LINKS
Amiram Eldar, Table of n, a(n) for n = 1..1000
EXAMPLE
For n = 1, prime(n) = 2, and the ratios generated are (3-2)/1 = 1 (not prime), (5-2)/1 = 3 (prime, first), (7-2)/1 = 5 (prime, second), (11-2)/1 = 9 (not prime) and (13-2)/1 = 11 (prime, third and selected a(1)).
MAPLE
A089487 := proc(n) local ct, q, p ;
ct := 0 ; q := ithprime(n) ; p := nextprime(q) ;
while true do
while true do
if type( (p-q)/(q-1), 'integer') then if isprime( (p-q)/(q-1)) then break; end if;
end if;
p := nextprime(p) ;
end do:
ct := ct+1 ;
if ct = 3 then return (p-q)/(q-1); end if;
p := nextprime(p) ;
end do:
end proc:
seq(A089487(n), n=1..44) ; # R. J. Mathar, Dec 06 2010
MATHEMATICA
a[n_, r_] := Module[{p = Prime[n], q, rat, c = 0}, q = p; While[c < r, q = NextPrime[q]; If[PrimeQ[rat = (q - p)/(p - 1)], c++]]; rat]; Table[a[n, 3], {n, 1, 100}] (* Amiram Eldar, Jun 29 2024 *)
PROG
(PARI) /* r is the occurrence desired 1=first, 2=second etc. */ diff2sqp2(n, r) = { forprime(q=2, n, c=0; forprime(p=q+1, n, y=(p-q)/(q-1); if(y==floor(y), if(isprime(y), c++; if(c==r, print1(y", "); break)) ) ) ) }
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Cino Hilliard, Dec 28 2003
EXTENSIONS
Edited and corrected by D. S. McNeil, Dec 06 2010
More terms from Amiram Eldar, Jun 29 2024
STATUS
approved