OFFSET
2,3
EXAMPLE
For n=4, a(4)=2 because 4 ->9 ->17
MATHEMATICA
pr[n_]:=Module[{c=If[EvenQ[n], 2n+1, 2n-1]}, Length[NestWhileList[ If[EvenQ[#], 2#+1, 2#-1]&, c, !PrimeQ[#]&]]]; Array[pr, 102, 2] (* Harvey P. Dale, Oct 05 2012 *)
PROG
(UBASIC) 10 cls 30 for I=2 to 100 32 H=I 40 if odd(H)=1 then goto 90 else goto 50 50 A=2*H+1:K=K+1 60 if prmdiv(A)=A then print I, K:goto 120 65 if K>10000 then print I, "no solution":goto 120 70 H=A:goto 40 90 A=2*H-1:K=K+1 100 if prmdiv(A)=A then print I, K:goto 120 105 if K>10000 then print I, "no solution":goto 120 110 H=A:goto 40 120 K=0 130 next
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Felice Russo, Sep 02 2002
EXTENSIONS
More terms from Jason Earls, Sep 04 2002
STATUS
approved