login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A160520 a(n) is the number of distinct values in the periodic part of the continued fraction of the square root of n-th nonsquare positive integer. 0
1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 3, 2, 1, 2, 4, 2, 3, 4, 3, 2, 1, 2, 3, 3, 2, 4, 2, 3, 3, 2, 1, 2, 2, 2, 2, 2, 4, 3, 3, 5, 3, 2, 1, 2, 4, 3, 4, 2, 2, 3, 2, 4, 3, 5, 3, 2, 1, 2, 5, 2, 4, 3, 4, 2, 3, 2, 2, 5, 4, 3, 3, 2, 1, 2, 2 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
LINKS
EXAMPLE
The 10th nonsquare positive integer is 13; sqrt(13) = cf[3;(1,1,1,1,6)], which has period 5, and 2 distinct values in its periodic part.
MATHEMATICA
Length@Union@Last@ContinuedFraction@Sqrt@#&/@Select[Range@100, !IntegerQ@Sqrt@#&] (* Giorgos Kalogeropoulos, May 05 2022 *)
PROG
(Python)
import math
def findperiod( d ) :
if len(d) == 0 :
return 0
for p in range( 1, len(d) - 1 ) :
isPeriod = True
for i in range(0, p) :
for j in range(i + p, len(d), p ) :
if not d[i] == d[j] :
isPeriod = False
break
if not isPeriod :
break
if isPeriod :
return len( set( d[:p] ) )
return -1
def nextv( a, b, n, less = True ) :
# print a, b, a[1]*a[1], n * a[0] * a[0]
d = -1
while (a[1]*a[1] < n * a[0] * a[0]) == less :
d += 1
a = ( a[0] + b[0], a[1] + b[1] )
a = ( a[0] - b[0], a[1] - b[1] )
return d, a, b
def generated( n ) :
maxperiod = 100
s = int( math.sqrt( n ) )
if s * s == n :
return []
a = (1, 0)
b = (0, 1)
ds = []
for i in range( maxperiod ):
d, b, a = nextv( a, b, n )
ds.append( d )
d, b, a = nextv( a, b, n, less = False )
ds.append( d )
return ds[1:]
maxn = 1000
ns = [x for x in range( maxn ) if not int( math.sqrt( x ) ) ** 2 == x ]
v = list(map( findperiod, map( generated, ns ) ))
if v.count( -1 ) == 0 :
print(v)
CROSSREFS
Sequence in context: A092505 A066086 A323406 * A235708 A353929 A297770
KEYWORD
nonn
AUTHOR
Dremov Dmitry (dremovd(AT)gmail.com), May 16 2009
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 04:14 EDT 2024. Contains 371918 sequences. (Running on oeis4.)