Algorithmically Finding the LCD (or decimal to fractions)

  • Thread starter Thread starter k_squared
  • Start date Start date
  • Tags Tags
    Fractions Lcd
k_squared
Messages
62
Reaction score
0
I wrote a program to convert decimals into fractions. It basically puts the decimal over the proper power of ten, and simplifies (at least, for nonreapeating fractions.) However, it uses a brute force method to find the LCD, and as a matter of aesthetics, I never like brute force. Does anyone know of some more efficient ways do do that?
 
Mathematics news on Phys.org
Just divide by two until it won't go in any longer, then divide by 5 until it won't go in any longer.

0.88 -> 88/100 = 44/50 = 22/25. Two won't go into the denominator anymore, and 5 won't go into the numerator, so you're done.

This let's you simplify 0.00000000000001048576 in twenty steps instead of a million.
 
Awesome.
Neat how it works like that - I wish I had a knack for seeing that kinda thing off the top of my head.
 
k_squared said:
Awesome.
Neat how it works like that - I wish I had a knack for seeing that kinda thing off the top of my head.

It's just the fundamental theorem of arithmetic (aka "uniqueness of prime factorization") at work. The only prime factors of any positive power of ten (eg 10 100 1000 etc) are 2 and 5.
 
CRGreathouse said:
This let's you simplify 0.00000000000001048576 in twenty steps instead of a million.

The Euclidean algorithm will find this is ONE step, since 1048576 divides 10^20. The reduced fraction is 1/95367431640625.
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
I'm interested to know whether the equation $$1 = 2 - \frac{1}{2 - \frac{1}{2 - \cdots}}$$ is true or not. It can be shown easily that if the continued fraction converges, it cannot converge to anything else than 1. It seems that if the continued fraction converges, the convergence is very slow. The apparent slowness of the convergence makes it difficult to estimate the presence of true convergence numerically. At the moment I don't know whether this converges or not.
Back
Top