2

Is there a way in math / programming to tell if a fraction (reciprocal in particular) does not end?

For example, 1/3 is 0.33 repeated, but 1/2 is just 0.5

Is there a way to find if 1/n for any natural number n is never ending?

Context: Writing a program and want to find out if I need to round 1/n (round in my way rather than whatever the machine does) before adding it to another digit.

E.g Since 1/3 is never ending, the machine will probably cut off some of the 3's at the end, and 1 + 1/3 = 1.33333. I want to be able to catch that 1/3 is never ending (or if 1/n is Not never ending) so that when I add a "never ending" number to 1, I can round it in my own way (i.e. I can round 0.3 up to 0.5, rather than the computers way of rounding never ending reciprocals / fractions).

Jay Patel
  • 235
  • Hint: when you're doing long division algorithm, if a reminder repeats at any step, then the decimal form is going to be recurring. If you hit the reminder 0 at any step, the fraction is a proper fraction. – yathish Oct 25 '18 at 03:33

1 Answers1

0

Hint: If a fraction in reduced form $\tfrac{a}{b}$ has a terminating decimal expansion, then $10^k\tfrac{a}{b}$ is an integer for sufficiently large $k$ (why is this?). Thus you can characterize the fractions with terminating decimal expansion solely in terms of $b$.

TomGrubb
  • 12,909