[go: up one dir, main page]

login
a(n) = smallest prime p such that continued fraction of (1 + sqrt(p))/2 has period length n.
6

%I #10 Aug 06 2017 22:27:58

%S 5,2,17,7,41,19,89,31,73,43,541,103,421,179,193,191,521,139,241,151,

%T 337,491,433,271,929,211,409,487,673,379,937,463,601,331,769,1439,

%U 2297,619,1033,1399,1777,571,1753,823,1993,739,1249,631,4337,1051,1321,751,1201

%N a(n) = smallest prime p such that continued fraction of (1 + sqrt(p))/2 has period length n.

%H Artur Jasinski, <a href="/A146363/b146363.txt">Table of n, a(n) for n=1..1000</a>

%p A := proc(n) option remember ; local c; try c := numtheory[cfrac](1/2+sqrt(n)/2,'periodic,quotients') ; RETURN(nops(c[2]) ); catch: RETURN(-1) end try ; end: A146363 := proc(n) local p,i ; for i from 1 do p := ithprime(i) ; if A(p) = n then RETURN(p) ; fi; od; end: for n from 1 do printf("%d, ",A146363(n)) ; od: # _R. J. Mathar_, Nov 08 2008

%t $MaxExtraPrecision = 300; s = 10; aa = {}; Do[k = ContinuedFraction[(1 + Sqrt[n])/2, 1000]; If[Length[k] < 190, AppendTo[aa, 0], m = 1; While[k[[s ]] != k[[s + m]] || k[[s + m]] != k[[s + 2 m]] || k[[s + 2 m]] != k[[s + 3 m]] || k[[s + 3 m]] != k[[s + 4 m]], m++ ]; s = s + 1; While[k[[s ]] != k[[s + m]] || k[[s + m]] != k[[s + 2 m]] || k[[s + 2 m]] != k[[s + 3 m]] || k[[s + 3 m]] != k[[s + 4 m]], m++ ]; AppendTo[aa, m]], {n, 1, 1200}]; Print[aa]; bb = {}; Do[k = 1; yes = 0&&PeimeQ[k]; Do[If[aa[[k]] == n && yes == 0, AppendTo[bb, k]; yes = 1], {k, 1, Length[aa]}], {n, 1, 22}]; bb (* _Artur Jasinski_ *)

%t aa = {}; Do[n = 1; While[m != Length[ContinuedFraction[(1 + Sqrt[Prime[n]])/2][[2]]], n++ ]; AppendTo[aa, Prime[n]], {m, 1, 100}]; aa (* _Artur Jasinski_, Feb 03 2010)

%Y Cf. A000290, A078370, A146326-A146345, A146348-A146360.

%K nonn

%O 1,1

%A _Artur Jasinski_, Oct 30 2008

%E a(25) replaced by 929 and extended by _R. J. Mathar_, Nov 08 2008