%I #34 Jul 20 2024 17:15:17
%S 1,2,1,2,4,2,1,2,2,5,4,2,1,2,6,2,6,6,4,2,1,2,4,5,2,8,4,4,4,2,1,2,2,2,
%T 3,2,10,8,6,12,4,2,1,2,6,5,6,4,2,6,7,6,4,11,4,2,1,2,10,2,8,6,8,2,7,5,
%U 4,12,6,4,4,2,1,2,2,5,10,2,6,5,2,8,8,10,16,4,4,11,4,2,1,2,12,2,2,9,6,8,15,2,6,6
%N Period of continued fraction for sqrt(m), m = n-th nonsquare.
%H Ray Chandler, <a href="/A013943/b013943.txt">Table of n, a(n) for n = 1..10000</a> (first 1000 terms from Vincenzo Librandi)
%H Kival Ngaokrajang, <a href="/A013943/a013943_1.pdf">Illustration of initial terms, periodic are colored</a>.
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/ContinuedFraction.html">Continued Fraction</a>.
%t nonSquares = Select[Range[120], !IntegerQ[Sqrt[#]]&]; a[n_] := Length[ Last[ ContinuedFraction[ Sqrt[ nonSquares[[n]] ]]]]; Table[a[n], {n, 1, Length[nonSquares]}] (* _Jean-François Alcover_, May 27 2013 *)
%o (Python)
%o from math import isqrt
%o from sympy.ntheory.continued_fraction import continued_fraction_periodic
%o def A013943(n): return len(continued_fraction_periodic(0,1,n+(k:=isqrt(n))+int(n>=k*(k+1)+1))[-1]) # _Chai Wah Wu_, Jul 20 2024
%Y Cf. A003285, A035015.
%K nonn,easy
%O 1,2
%A _Clark Kimberling_