login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A013943
Period of continued fraction for sqrt(m), m = n-th nonsquare.
9
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, 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, 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
OFFSET
1,2
LINKS
Ray Chandler, Table of n, a(n) for n = 1..10000 (first 1000 terms from Vincenzo Librandi)
Eric Weisstein's World of Mathematics, Continued Fraction.
MATHEMATICA
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 *)
PROG
(Python)
from math import isqrt
from sympy.ntheory.continued_fraction import continued_fraction_periodic
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
CROSSREFS
Sequence in context: A059149 A273917 A186187 * A164281 A082693 A225081
KEYWORD
nonn,easy
STATUS
approved