login
A368882
a(n) is the first number k such that the continued fraction for prime(k)/k has length n.
0
1, 2, 3, 8, 18, 23, 48, 49, 142, 128, 302, 714, 1584, 1809, 3733, 4641, 11281, 12533, 27170, 70759, 170717, 206956, 445933, 431440, 1096122, 909272, 2311327, 7107627, 7371755, 18882236, 18911330, 48297584, 120815756, 125176520, 299244034, 794635896, 1572930576, 1713395072, 839199226
OFFSET
1,2
COMMENTS
a(n) is the first number k such that the continued fraction for k/prime(k) has length n+1.
FORMULA
A107901(a(n)) = n.
A107898(a(n)) = 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
Sequence in context: A290878 A096254 A091765 * A036746 A232165 A129955
KEYWORD
nonn
AUTHOR
Robert Israel, Jan 08 2024
EXTENSIONS
More terms from David A. Corneth, Jan 09 2024
STATUS
approved