# [Tutor] Finding a repeating sequence of digits

Sat Jan 2 16:31:02 CET 2010

```2010/1/2 Robert Berman <bermanrl at cfl.rr.com>:
> Hi,
>
> I am trying to build an algorithm or methodology which will let me tell
> if a decimal has a repeating sequence of digits and if it does have that
> attribute, what is the sequence of digits. For example, 1/3.0 =
> 0.333333333..By eyeballing we know it has a repeating sequence and we
> know that the sequence is .3333.....A little more complex is 1/7.0 =
> 0.142857142857 but still is equivalent. A harder example is 45/56.0 =
> 0.8035714285714286. Here we have a repeating sequence but it comes after
> the first three digits.
>
> What I am looking for are ideas and suggestions looking for patterns. I
> do know I should use a relatively large precision as repeating values
> may constitute a rather long sequence. I did see, on Google, a
> suggestion to use a precision of 1000.
>
> Thank you for any and all ideas and suggestions.
>
>
> Robert Berman
>
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

When it comes to number theory, I always turn first of all to wikipedia.
http://en.wikipedia.org/wiki/Repeating_decimal

If that doesn't help, I usually turn to Wolfram:
http://mathworld.wolfram.com/RepeatingDecimal.html

Between the two, and the links therefrom, there's probably all the
information you need.

--

There are 10 types of people in the world: those who know binary,
those who do not, and those who are off by one.
```