Revision history [back]

Length of preperiod and period of a rational number

I found something for Continued fractions, but I ask myself:

I there an easy way to get the lengths of preperiod and period of a rational number?

It seems for Rational numbers I can only use a.period(), not a.preperiod().

For, say, 1/7 = 0.142857142857... I shoul get somethink like:
Length of preperiod: 0
Length of period: 6

a = 1/7
print float(a)
print 'a.period() gives me the length of the period:', a.period()
print 'a.preperiod() does not work', #print a.preperiod()


Out:

0.142857142857
a.period() gives me the length of the period: 6
a.preperiod() does not work


Length of preperiod and period of a rational number

I found something for Continued fractions, but I ask myself:

I there an easy way to get the lengths of preperiod and period of a rational number?

It seems for Rational numbers I can only use a.period(), not a.preperiod().

For, say, 1/7 = 0.142857142857... I shoul get somethink like:
Length of preperiod: 0
Length of period: 6

a = 1/7
print float(a)
print 'a.period() gives me the length of the period:', a.period()
print 'a.preperiod() does not work', #print a.preperiod()


Out:

0.142857142857
a.period() gives me the length of the period: 6
a.preperiod() does not work


Length of preperiod and period of a rational number

I found something for Continued fractions, but I ask myself:

I there an easy way to get the lengths of preperiod and period of a rational number?

It seems for Rational numbers I can only use a.period(), not a.preperiod().

For, say, 1/7 = 0.142857142857... I shoul get somethink like:
Length of preperiod: 0
Length of period: 6

a = 1/7
print float(a)
print 'a.period() gives me the length of the period:', a.period()
print 'a.preperiod() does not work', #print a.preperiod()


Out:

0.142857142857
a.period() gives me the length of the period: 6
a.preperiod() does not work


Length Lengths of preperiod and period of a rational number

I found something for Continued fractions, but I ask myself:

I there an easy way to get the lengths of preperiod and period of a rational number?

It seems for Rational numbers I can only use a.period(), not a.preperiod().

For, say, 1/7 = 0.142857142857... I shoul get somethink something like:
Length of preperiod: 0
Length of period: 6

a = 1/7
print float(a)
print 'a.period() gives me the length of the period:', a.period()
print 'a.preperiod() does not work', #print a.preperiod()


Out:

0.142857142857
a.period() gives me the length of the period: 6
a.preperiod() does not work


Lengths of preperiod and period of a rational number

I found something for Continued fractions, but I ask myself:

I there an easy way to get the lengths of preperiod and period of a rational number?

It seems for Rational numbers I can only use a.period(), not a.preperiod().

For, say, 1/7 = 0.142857142857... I shoul get something like:
Length of preperiod: 0
Length of period: 6

a = 1/7
print float(a)
print 'a.period() gives me the length of the period:', a.period()
print 'a.preperiod() does not work', #print a.preperiod()
#a.preperiod()


Out:

0.142857142857
a.period() gives me the length of the period: 6
a.preperiod() does not work


Lengths of preperiod and period of a rational number

I found something for Continued fractions, but I ask myself:

I there an easy way to get the lengths of preperiod and period of a rational number?

It seems for Rational numbers I can only use a.period(), not a.preperiod().

For, say, 1/7 = 0.142857142857... I shoul shoud get something like:
Length of preperiod: 0
Length of period: 6

a = 1/7
print float(a)
print 'a.period() gives me the length of the period:', a.period()
print 'a.preperiod() does not work', #a.preperiod()


Out:

0.142857142857
a.period() gives me the length of the period: 6
a.preperiod() does not work


Lengths of preperiod and period of a rational number

I found something for Continued fractions, but I ask myself:

I there an easy way to get the lengths of preperiod and period of a rational number?

It seems for Rational numbers I can only use a.period(), not a.preperiod().

For, say, 1/7 = 0.142857142857... I shoud should get something like:
Length of preperiod: 0
Length of period: 6

a = 1/7
print float(a)
print 'a.period() gives me the length of the period:', a.period()
print 'a.preperiod() does not work', #a.preperiod()


Out:

0.142857142857
a.period() gives me the length of the period: 6
a.preperiod() does not work

 8 None FrédéricC 2904 ●3 ●31 ●58

Lengths of preperiod and period of a rational number

I found something for Continued fractions, but I ask myself:

I there an easy way to get the lengths of preperiod and period of a rational number?

It seems for Rational numbers I can only use a.period(), not a.preperiod().

For, say, 1/7 = 0.142857142857... I should get something like:
Length of preperiod: 0
Length of period: 6

a = 1/7
print float(a)
print 'a.period() print(float(a))
print('a.period() gives me the length of the period:', a.period()
print 'a.preperiod() a.period())
print('a.preperiod() does not work', #a.preperiod()
#a.preperiod())


Out:

0.142857142857
a.period() gives me the length of the period: 6
a.preperiod() does not work