Let a fraction be represented as p/q, where p and q are integers and the fraction is in its simplest form (GCD(p, q) = 1).
A decimal number can be written as an integer divided by a power of 10. For example, 0.375 = 375 / 1000. So, for p/q to be a terminating decimal, it must be expressible as k / (10^n) for some integers k and n.
This means q must be a divisor of 10^n. The prime factorization of 10 is 2 x 5. Therefore, the prime factorization of 10^n is 2^n * 5^n. For q to be a divisor of 10^n, its prime factors must only be 2s and 5s.