"Why can any fraction whose denominator has only 2s and 5s in its prime factorization can be written as a terminating decimal?"

To be perfectly correct you must define "fraction" a bit narrower.
9/3 terminates
ozo
3 does not have only 2s and 5s in its prime factorization, so whether 9/3 terminates is irrelevant.
aburr
"3 does not have only 2s and 5s in its prime factorization, so whether 9/3 terminates is irrelevant. "
true
But it is relvant when considering the converse (I know, that was not asked)
.... Thinkpads_User