duongthang wrote:how do you know that if the denominator is in form 2^n, 5^m, or 2^n*5^m , the fractiom is terminating.
If you have, say, the fraction a/2^n, you can multiply on the top and bottom by 5^n to get
(a*5^n)/(2^n * 5^n) = (a*5^n)/(10^n)
Since you have a power of 10 (so a number like 10, or 100, or 1000, etc) in the denominator, this must be a terminating decimal. Similarly, if you have a fraction like
21/125 = 21/5^3
we can calculate the decimal of this very quickly by multiplying the top and bottom by 2^3
21/5^3 = (2^3 * 21)/(2^3 * 5^3) = 162/10^3 = 162/1000 = 0.162
As long as the only primes in the denominator are 2, 5, or both, you can get 10^x in the denominator by multiplying on the top and bottom by a well-chosen power of 2 or 5. Since you can get a denominator that is a power of 10, the decimal must terminate.