login
a(n) is the first number k such that the continued fraction for prime(k)/k has length n.
0

%I #24 Jan 09 2024 16:56:37

%S 1,2,3,8,18,23,48,49,142,128,302,714,1584,1809,3733,4641,11281,12533,

%T 27170,70759,170717,206956,445933,431440,1096122,909272,2311327,

%U 7107627,7371755,18882236,18911330,48297584,120815756,125176520,299244034,794635896,1572930576,1713395072,839199226

%N a(n) is the first number k such that the continued fraction for prime(k)/k has length n.

%C a(n) is the first number k such that the continued fraction for k/prime(k) has length n+1.

%F A107901(a(n)) = n.

%F A107898(a(n)) = n + 1.

%e 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.

%p V:= Vector(27): count:= 0: p:= 0:

%p for n from 1 while count < 50 do

%p p:= nextprime(p);

%p v:= nops(Term(NumberTheory:-ContinuedFraction(p/n,all));

%p if v <= 27 and V[v] = 0 then V[v]:= n; count:= count+1 fi;

%p od:

%p convert(V,list);

%t a[n_]:=Module[{k=1}, While[Length[ContinuedFraction[Prime[k]/k]]!=n, k++]; k]; Array[a,20] (* _Stefano Spezia_, Jan 09 2024 *)

%o (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

%Y Cf. A107898, A107901.

%K nonn

%O 1,2

%A _Robert Israel_, Jan 08 2024

%E More terms from _David A. Corneth_, Jan 09 2024