1 | initial version |
# Length of Preperiod and Period
a = 1
b = 2*7
u = denominator(a/b).valuation(2)
v = denominator(a/b).valuation(5)
def PreperiodLength(a,b): return max(u,v)
m = denominator(a/b) / (2^u*5^v)
y = 1/m
def PeriodLength(a,b):
if m == 1:
return 0
else:
return y.period()
#print 'm=', m
#print a,'/',b, '=', float(a/b)
print a,'/',b, '=', numerical_approx(a/b, digits=PreperiodLength(a,b)+PeriodLength(a,b))
print 'PreperiodLength:', PreperiodLength(a,b)
print 'PeriodLength:', PeriodLength(a,b)
Out:
1 / 14 = 0.07142857
PreperiodLength: 1
PeriodLength: 6
2 | No.2 Revision |
#
a = 1
b = 2*7
u = denominator(a/b).valuation(2)
v = denominator(a/b).valuation(5)
def Out:
1 / 14 = 0.07142857
PreperiodLength: 1
PeriodLength: 6
3 | No.3 Revision |
a = 1
b = 2*7
u = denominator(a/b).valuation(2)
v = denominator(a/b).valuation(5)
def PreperiodLength(a,b):
return max(u,v)
m = denominator(a/b) / (2^u*5^v)
y = 1/m
def PeriodLength(a,b):
if m == 1:
return 0
else:
return y.period()
# print('m #print('m = {}'.format(m))
# print('{} #print('{} / {} = {}'.format(a, b, float(a/b)))
print('{} / {} = {}'.format(a, b, numerical_approx(a/b, digits=PreperiodLength(a,b) + PeriodLength(a,b))
PeriodLength(a,b))))
print('PreperiodLength: {}'.format(PreperiodLength(a,b)))
print('PeriodLength: {}'.format(PeriodLength(a,b))
{}'.format(PeriodLength(a,b)))
Out:
1 / 14 = 0.07142857
PreperiodLength: 1
PeriodLength: 6
4 | No.4 Revision |
a = 1
b = 2*7
u = denominator(a/b).valuation(2)
v = denominator(a/b).valuation(5)
def PreperiodLength(a,b):
PreperiodLength(a,b): return max(u,v)
m = denominator(a/b) / (2^u*5^v)
y = 1/m
def PeriodLength(a,b):
if m == 1:
return 0
else:
return y.period()
#print('m = {}'.format(m))
#print('{} / {} = {}'.format(a, b, float(a/b)))
print('{} / {} = {}'.format(a, b, numerical_approx(a/b, digits=PreperiodLength(a,b) + PeriodLength(a,b))))
print('PreperiodLength: {}'.format(PreperiodLength(a,b)))
print('PeriodLength: {}'.format(PeriodLength(a,b)))
Out:
1 / 14 = 0.07142857
PreperiodLength: 1
PeriodLength: 6
5 | No.5 Revision |
a = 1
b = 2*7
u = denominator(a/b).valuation(2)
v = denominator(a/b).valuation(5)
def PreperiodLength(a,b): return max(u,v)
m = denominator(a/b) / (2^u*5^v)
y = 1/m
def PeriodLength(a,b):
if m == 1:
return 0
else:
return y.period()
#print('m = {}'.format(m))
#print('{} / {} = {}'.format(a, b, float(a/b)))
print('{} / {} = {}'.format(a, b, numerical_approx(a/b, digits=PreperiodLength(a,b) + PeriodLength(a,b))))
print('PreperiodLength: {}'.format(PreperiodLength(a,b)))
print('PeriodLength: {}'.format(PeriodLength(a,b)))
Out:
1 / 14 = 0.07142857
PreperiodLength: 1
PeriodLength: 6