## 1. How to compute a repeating sequence

### A notation of repeating sequence and computation method

In this chapter we compute the repeating sequence and its length for
circulating fraction of **1/p where p is prime up to 100** except 2 and 5.

For example,

1/7 = 0.[142857], length=6

1/11 = 0.[09], length=2

1/13 = 0.[76923], length=6

...

Formal notation of repeating decimal is
to put a dot on the begin and end of repeating letter.
But it is inconvenient for HTML notation, so in this chapter
we donote as above, that is, locating repeating decimals between [ ] .

### Program

When we compute 1 divede by 7 by hand, we do as follows;

1/7=0 ... 1

put "0" at the right of "1", compute 10/7

10/7=1 ... 3

put "0" at the right of "3", compute 30/7

......

repeating the procedure that "put 0 at the right of previous remainder and divide by 7".

When the remainder is equal to "1", the next circulation starts.

The remainders dividing by p are,

1, 2, ... , p-1

so the length of repeating decimals is at most p-1.

10 ' cycle
20 A=1:P=7
30 B=A*10\P:A=res:print B;:if A<>1 then 30

We compute the repeating sequence and its length for

circulating fraction of **1/p where p is prime up to 100** except 2 and 5.

5 ' cycle_p
10 for I=1 to 25:N=prm(I):if or{N=2,N=5} then 100
20 int "n=";N
30 A=1:Length=0
40 B=A*10\N:A=res:print B;:inc Length:if A<>1 then 40
50 print:print Length
60 next I

Repeating sequences of 1/p for prime between 2 ≤ p < 100 are here.

E-mail : kc2h-msm@asahi-net.or.jpHisanori Mishima