here is how i would approach it

for any number a/b reduce it to the simplest form (i.e. cancel all common factors) now if b contains prime numbers (other than 2 or 5) then the decimal will not terminate...

copy pasting some relevant information from wikipedia

Fractions with prime denominators

A fraction in lowest terms with a prime denominator other than 2 or 5 (i.e. coprime to 10) always produces a recurring decimal. The period of the recurring decimal, 1/ p, where p is prime, is either p − 1 (the first group) or a divisor of p − 1 (the second group).

Examples of fractions of the first group are:

1/7 = 0.142857...; 6 repeating digits

1/17 = 0.0588235294117647...; 16 repeating digits

1/19 = 0.052631578947368421...; 18 repeating digits

1/23 = 0.0434782608695652173913...; 22 repeating digits

1/29 = 0.0344827586206896551724137931...; 28 repeating digits

The list can go on to include the fractions 1/47, 1/59, 1/61, 1/97, 1/109 etc.

This is to say:

106 − 1 = 999,999 (6 digits of 9) is divisible by 7;

1016 − 1 = 9,999,999,999,999,999 (16 digits of 9) is divisible by 17;

1018 − 1 = 999,999,999,999,999,999 (18 digits of 9) is divisible by 19; etc.

These can be deduced from Fermat's little theorem.

It can also be generalised to say that p − 1 digits of 1 (or 2, 3, 4, 5, 6, 7, 8, 9) is divisible by p, which is a prime number other than 2 or 5.

The following multiplications exhibit an interesting property:

2/7 = 2 Ã— 0.142857... = 0.285714...

3/7 = 3 Ã— 0.142857... = 0.428571...

4/7 = 4 Ã— 0.142857... = 0.571428...

5/7 = 5 Ã— 0.142857... = 0.714285...

6/7 = 6 Ã— 0.142857... = 0.857142...

That is, these multiples can be obtained from rotating the digits of the original decimal of 1/7. The reason for the rotating behaviour of the digits is apparent from an arithmetics exercise of finding the decimal of 1/7.

Of course 142857 Ã— 7 = 999999, and 142 + 857 = 999.

Decimals of other prime fractions such as 1/17, 1/19, 1/23, 1/29, 1/47, 1/59, 1/61, 1/97, 1/109 all exhibit the same property.

Fractions of the second group are:

1/3 = 0.333.... which has 1 repeating digit.

1/11 = 0.090909... which has 2 repeating digits.

1/13 = 0.076923... which has 6 repeating digits.

Note that the following multiples of 1/13 exhibit the discussed property of rotating digits:

1/13 = 0.076923...

3/13 = 0.230769...

4/13 = 0.307692...

9/13 = 0.692307...

10/13 = 0.769230...

12/13 = 0.923076...

And similarly these multiples:

2/13 = 0.153846...

5/13 = 0.384615...

6/13 = 0.461538...

7/13 = 0.538461...

8/13 = 0.615384...

11/13 = 0.846153...

Again, 076923 Ã— 13 = 999999, and 076 + 923 = 999.

[edit] Why all repeating or terminating decimals must be rational numbers

Given a repeating decimal, it is possible to calculate the fraction which produced it. For example:

x = 0.333333...

10x = 3.33333... (multiplying each side of the above line by 10)

9x = 3 (subtracting the 1st line from the 2nd)

x = 3/9 = 1/3 (simplifying)

Another example:

x = 0.18181818...

100x = 18.181818...

99x = 18

x = 18/99 = 2/11

From this kind of argument, we can see that the period of the repeating decimal of a fraction n/d will be (at most) the smallest number k such that 10k − 1 is divisible by d.

For example, the fraction 2/7 has d = 7, and the smallest k that makes 10k − 1 divisible by 7 is k = 6, because 999999 = 7 Ã— 142857. The period of the fraction 2/7 is therefore 6.

for more ....

http://en.wikipedia.org/wiki/Recurring_ ... nominators