martes, 5 de junio de 2018

Fractions and decimals

Fractions and decimal representation

The following is a Python 3.7. It must be previously installed,

#Fractions and decimal representation
print('Type integer part and no periodical part, without decimal point')
a=int(input())
print('Type the same figures and add the figures of the first period')
b=int(input())
numerator=b-a
print('Type 9 a number of times equal to number of figures in the period')
print('and type 0 a number of times equal to number of figures')
print('before the periodic part, and to the right of decimal point')
denominator=int(input())
print('The generator fraction is',numerator,'/',denominator)

Example (1): Given 25.36124242424...

Type integer part and no periodical part, without decimal point
25361
Type the same figures and add the figures of the first period
2536124
Type 9 a number of times equal to number of figures in the period
and type 0 a number of times equal to number of figures
before the periodic part, and to the right of decimal point
99000
The generator fraction is 2510763 / 99000
or, simplyfying, 836921/33000

Example(2): Given 4.23232323...

Type integer part and no periodical part, without decimal point
4
Type the same figures and add the figures of the first period
423
Type 9 a number of times equal to number of figures in the period
and type 0 a number of times equal to number of figures
before the periodic part, and to the right of decimal point
99
The generator fraction is 419 / 99

No hay comentarios:

Publicar un comentario