OFFSET
1,2
COMMENTS
a(n) is the first number k such that the continued fraction for k/prime(k) has length n+1.
EXAMPLE
a(4) = 8 because prime(8) = 23 and the continued fraction for 23/8 is [2; 1, 7] (i.e., 23/8 = 2 + 1/(1 + 1/7)) with 3 terms, and this is the first continued fraction of 3 terms that occurs.
MAPLE
V:= Vector(27): count:= 0: p:= 0:
for n from 1 while count < 50 do
p:= nextprime(p);
v:= nops(Term(NumberTheory:-ContinuedFraction(p/n, all));
if v <= 27 and V[v] = 0 then V[v]:= n; count:= count+1 fi;
od:
convert(V, list);
MATHEMATICA
a[n_]:=Module[{k=1}, While[Length[ContinuedFraction[Prime[k]/k]]!=n, k++]; k]; Array[a, 20] (* Stefano Spezia, Jan 09 2024 *)
PROG
(PARI) upto(n) = {my(res = [], t = 0); forprime(p = 2, oo, t++; if(t >= n, return(res)); c = #contfrac(p/t); if(c > #res, res = concat(res, vector(c - #res, i, oo)); res[c] = min(res[c], t)))} \\ David A. Corneth, Jan 09 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert Israel, Jan 08 2024
EXTENSIONS
More terms from David A. Corneth, Jan 09 2024
STATUS
approved