[Tutor] Finding a repeating sequence of digits

Lie Ryan lie.1296 at gmail.com
Sat Jan 2 16:10:03 CET 2010


On 1/2/2010 1:01 PM, Robert Berman wrote:
> 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.

Does this gives you any idea?

1  / 3 = 0 rem 1
10 / 3 = 3 rem 1 <- we've encountered '1' in "1 / 3 = 0 rem 1"
... sequence "3" repeats

1  / 7 = 0 rem 1
10 / 7 = 1 rem 3
30 / 7 = 4 rem 2
20 / 7 = 2 rem 6
60 / 7 = 8 rem 4
40 / 7 = 5 rem 5
50 / 7 = 7 rem 1 <- we've encountered '1' in "1 / 7 = 0 rem 1"
... sequence "142857" repeats

45  / 56 = 0 rem 45
450 / 56 = 8 rem 2
20  / 56 = 0 rem 20
200 / 56 = 3 rem 32
320 / 56 = 5 rem 40
400 / 56 = 7 rem 8
80  / 56 = 1 rem 24
240 / 56 = 4 rem 16
160 / 56 = 2 rem 48
480 / 56 = 8 rem 32 <- we've encountered '32' in "200 / 56 = 3 rem 32"
... sequence "571428" repeats



More information about the Tutor mailing list