A228488 Period length of trace(sqrt(n)).
0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 3, 1, 1, 0, 1, 1, 4, 1, 2, 4, 1, 1, 0, 1, 1, 1, 4, 1, 6, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 6, 1, 4, 8, 1, 1, 0, 1, 1, 4, 4, 4, 1, 1, 2, 4, 4, 1, 7, 1, 1, 0, 1, 1, 8, 1, 6, 4, 6, 1, 5, 3, 1, 8, 4, 1, 1, 1, 0, 1, 1, 1, 4, 6
Offset: 0
Keywords
Examples
a(13) = 3 because the trace(sqrt(13)) = 110(repeated) has period length 3.
Programs
-
Mathematica
$MaxExtraPrecision = Infinity; period[seq_] := (If[Last[#1] == {} || Length[#1] == Length[seq] - 1, 0, Length[#1]] &)[NestWhileList[Rest, Rest[seq], #1 != Take[seq, Length[#1]] &, 1]]; periodicityReport[seq_] := ({Take[seq, Length[seq] - Length[#1]], period[#1], Take[#1, period[#1]]} &)[Take[seq, -Length[NestWhile[Rest[#1] &, seq, period[#1] == 0 &, 1, Length[seq]]]]] (*output format: {initial segment, period length, period}*) t[{x_, y_, }] := t[{x, y}]; t[{x, y_}] := Prepend[If[# > y - #, {y - #, 1}, {#, 0}], y]&[Mod[x, y]]; userIn2[{x_, y_}] := Most[NestWhileList[t, {x, y}, (#[[2]] > 0) &]]; z = 160; pr = Table[If[IntegerQ[Sqrt[n]], {0, 0}, p = Convergents[Sqrt[n], z]; pairs = Table[{Numerator[#], Denominator[#]} &[p[[k]]], {k, 1, z}]; periodicityReport[ Most[Last[Map[Map[#[[3]] &, Rest[userIn2[#]]] &, pairs]]]]], {n, 120}] m = Map[#[[2]] &, pr] (* Peter J. C. Moses, Aug 22 2013 *)
Comments