Logo

Greetings from The On-Line Encyclopedia of Integer Sequences!

Hints

Search: id:A160520
Displaying 1-1 of 1 results found. page 1
     Format: long | short | internal | text      Sort: relevance | references | number      Highlight: on | off
A160520 a(n) = number of different values in period of continued fraction of square root of n-th nonsquare integer. +0
1
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; listen)
OFFSET

1,2

EXAMPLE

for n = 10 : ( 2,3,5,6,7,8,10,11,12,_13_ )

sqrt(13) = [3;(1,1,1,1,6)].

period length : 5, different values in period : 2

PROGRAM

(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 = map( findperiod, map( generated, ns ) )

if v.count( -1 ) == 0 :

....print v

CROSSREFS

Adjacent: A013943, A099725

Sequence in context: A068068 A092505 A066086 this_sequence A145866 A103318 A002321

Adjacent sequences: A160517 A160518 A160519 this_sequence A160521 A160522 A160523

KEYWORD

nonn

AUTHOR

Dremov Dmitry (dremovd(AT)gmail.com), May 16 2009

page 1

Search completed in 0.002 seconds

Lookup | Welcome | Find friends | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Puzzles | Hot | Classics
More pages | Superseeker | Maintained by N. J. A. Sloane (njas@research.att.com)

Last modified November 24 14:25 EST 2009. Contains 167438 sequences.


AT&T Labs Research