THE GENERAL QUASI-ORDER ALGORITHM IN NUMBER THEORY

. This paper deals with a generalization of the Binary Quasi-Order Theorem. This generalization involves a more complicated algorithm than (0.2)t. Some remarks are made on relative merits of two dual algorithms called the -algorithm and the G-algorithm. Some illustrative examples are given.


O. INTRODUCTION
In [HP3] the authors gave an algorithm for computing the quasi-order of 2 mod b for any udd number b.Here we understand the quasi-order of t mod b, where b,t are mutually prime positive integers, to be the smallest integer k such that t k: +l modulo b.The algorithm, which also determined whether tk +I or tk -I, was based on a procedure for olding arbitrarily good approximations to regular star polygons (with b sldes) from straight strips of paper, developed in [HP1,2].
All the number-theoretical work which accompanied the evolution of the algurithm in [HP1,2,3] suggested that it should be possible to generalize the algorithm rom the case of t 2 to the case of a general positive integer; all that should be lost would be the original geometrical significance.However, the generalization propused and studled in [HP4] had the serious defect that, though it was a generalization o$ the Quasi-Order T'heorem of [HP3], it was not an algorithm.Let us briefly review the situation to clarify ths point.
We introduced in [HP3] the symbol k2 where ai b are odd, a < b/2, and k b=a.+2 ai+ 1, 1,2 r (ar+ a I) (U.Z)2 Such a symbol always exists for a glven b and a al, and is uniquely determlned by b arid a up to repetition.Then we proved the following theorem in [HP3].
Theorem 0.1 (The Bnary .Quasi-Order Theorem) If (0.1) is reduced (i.e., gcd (b,al) I) and contracted (i.e., the symbol involves no repeated a then the r quas-order of 2 mod b is k Z k, and, in fact, 2k -,(-]r mod b.

I=I
We chose a proof of this theorem which contained steps of great interest from the geometrlc (paper-folding) point of vew, but which wa not the most dlrect proof avallable.The generalization we proved n [HP4] was ths" Theorem 0.2 S.uppose b prime to t, and ta, and suppose a < b/t.If the symbol (0.1) mean that k. b a + t a+I, 1,2 r (at+ (0.2) t then, provided (0.1) is reduced and contracted, the quasi-order of t mod b is k and t k m (-i) r mod b. k In fact, we proved a refinement of this if r is even, since then we did not that (0.1) be reduced but merely that gcd (b,al)l(t-1).require However, it is no longer true, if t > 3, that a symbol in the sense of Theorem 0.2 always exists (for example, there is no symbol with t 3, b 11, whatever value we give to al); and much of the discussion in [HP4] centered on specifying criteria for the exlstence of a symbol.
In this paper we give a somewhat different generalization of Theorem 0.1, though it Is very similar in spirit to Theorem 0.2.This generalization involves a more complicated algorithm than (0.2)t but It has the compensating merit that it is genuinely an algorithm.The condition a < b/t is replaced by a < b/2 (after all, both are generalizations of the condition a < b/2, imposed if t 2!); but now, given any two positive integers b and , with b prime to t, and given a a not divisible by t, there is always a (modified) symbol (0.1) and a (generalized)   quasi-order theorem holds.This is our Theorem 2.2.
In fact, there are two dual (or mutually inverse) algorithms for generating a symbol from b and a.We use one (which we call the @-algorithm and which generalizes (0.2)2) to prove that symbols, suitably modified, always exist (for gven b,a), and the dual algorithm (which we call the c0-algorithm) to prove the Quasi-Order Theorem.Our impression is that the -algorithm would appeal to an intelligent human being, while the c0-algorithm is much better adapted to the computer.
The paper continues with some remarks on the relation of the proof to arguments given in [HP3,4] and on the relative merits of the two algorithms; and concludes with some illustrative examples.

PRELIMINARY RESULTS
Throughout this section, b,t will be fixed coprime positive integers with t > 2. The following lemma is quite obvious.Lemma 1.1 Let T be a set of t consecutive integers, and let a be an arbitrary in.teger.Then the set {qb+a, q T} o__[f t integers runs through the complete set of residues modulo t.Proposition 1.2 Suppose t # a. Then (i) if t is odd,.the set of integers {qb+a, < q <_ "--; qb-a, <q_ <_contains precisely one integer divisible by t; (ii) if t is even, the set of intecers{qb+a, < q <-i; qb-a, < q <} contains precisely one integer divisible by t.Proof We will be content to prove case (i).By Lemma 1.1, the set of integers q --2--< q -< contains exactly one integer qob+a divisible by t; but qo # 0 since ta.If qo > O, then thls is the integer required by our proposition, since if tl(qb-a) then tl(-qb+a).If qo O, then -(qob+a) is the integer required by our proposltion.
Let us write b + (-l)Ea, E 0 or I, (i.I) for the integer described in Proposition 1.2; thus < < t-I if t is odd 2 _< _<if t Is even and E 0 if t s even and (1.2) Further, suppose b > 3 and let S be the set of positive integers a such that ta and a < b/2.For a ( S, it is plain from (1.2) that the integer (1.1) is always positive, so that there exists a maximal k, with k > 1, such that b + (-I) E t k a a a E S, a > 0 (1.3) Since k is maximal, ta' We claim more, namely, Theorem 1.3 The function a a' is a permutation of the set S.
b tb Proof Assume first that t is odd.Then k >_ and tka < b + T' so that a' < b/2 and so a' E S. Thus a a' is a function 4"S S. It only remains to show that is surjective, since S is a finite set.
A small inodification is needed if t is even.Again, in (1.3), k > and tka < b so that a' 6 S, a.d we have a function :S S. To show that is surjectlv we proceed as above as far as (1.4).We now claim that :o; For if E 0 and q > t/2, then, from (1.4), tka > b, contradicting the minimality of k; and if and q >_ + i, then tka > + b T b, again contradicting the minimality of k.Thus (1.5) is established.Once more we conclude that ta; for if tla, then tlq, and q > is constrained by (I.5).We involve Propositlon 1.2(Ii), together with (1.4), to complete the proof of the theorem.
Remark If t 2, then the integer described in Proposition 1.2(ii) is simply b-a.Thus (1.3) yields in this case the rule b-a 2ka (1.6) whlch was precisely the basis of the algorithm in Theorem 0.1; see (0.2) 2 (1.3) provides a generalization of that basis.Thus 2. THE GENERAL QUASI-ORDER ALGORITHM Let b and t be any two coprime positive integers; define S as in Section I. Since 'S S is a permutation, we may start with any a ( S and we will (2.2) Note that (2.1) is contracted, in the sense that there is no repeat among the ai's.
We will not systematically develop the properties of the symbol (2.1) as in [HP3], but will proceed as directly as possible to the main theorem.We first prove an easy emma.
Lemma 2.1 In the symbol (2.1), gcd (b,ai) is independent of i.
Proof This follows immediately from (2.2) and the fact that b,t are mutually prime.
We call the symbol (2.1) reduced if gcd (b,ai) I; notice that this is a change r r of terminology from [HP3,4].Now, in (2.1), let k Z k i, E Z c i. We prove i=l i=l Theorem 2.2 (The General Quasi-order Algorithm) Let b and t be any two coprime posltive integers.Let the symbol (2.1) be contracted and reduced.Then k is the quasi-order of t mod b.In fact, t k=-(-i) c modulo b.
(2.3) Proof In the course of proving Theorem 1.3, we found an explicit form for 0, the inverse of b.S S. Thus 0(a') a, where K is minimal such that tka > b/2 and (1.4) holds" moreover, the value of q in (1.4) is constrained exactly as in (I.2).
We now concentrate on the -algorithm, that is, we make (1.4) the fundamental rule for generating a symbol and write (2.1) in 'skew-reverse' notation as c r Cr_ c 2 c r-I r-2.
1 r nr n n r-2 nr (If one were to regard , rather than b, as the fundamental algorithm, it would be natural to introduce a change in the format of our t-symbol to relate it better to =a " =k i<r =k;n = i< r n = (2.4).)Then c r r r+l-i' r-i' r r r-i r r" Z i' n n i, then we must prove that is the quasi-order of t rood b, Then s.i+l :_ +ts modulo b, for all j.Indeed, si+ Im ts i modulo b unless sj t c i, sj+ ci+ and n I; in that case, Sj+l-tsj modulo b.
We claim that sj +c modulo b unless j or + i.For if sj c modulo b, then, since 0 < s i, c < b/2, we must have s i c I. This is impossible if s iJ tnci n >_ I, since t#c I.It is also impossible if s i c (unless I) since our symbol is contracted.Again if s i -c modulo b, then bl(sj + Cl) but 0 < s i + c b, which is an obvious contradiction.Thus is the minimum m such that tmc lm +_c modulo b.
But since, by Lemma 2.1, b, c are mutually prime, it follows that / is the minimum m such that tm-+i modulo b and, from (2.5), that t2m (-1) n modulo b.This completes the proof.
Remarks (a) If t 2, then E for all i, so that r.Thus Theorem 2.2 does generalize the binary quasi-order theorem.Of course, the proof given here applies in the special case and, indeed, it then reduces to an argument equivalent to that shown to us by Gerald Preston.
(b) Theorem 0.2 may also be proved along the lines of our proof of Theorem 2.2.However, as we mentioned, that theorem had a refinement which our proof does not yield.Namely, it was shown that, if a a 2 a r k k k 2 r k k. i=1 is a t-symbol in the sense of [HP4], that is, satisfying (O.2)t, if it is contracted, and if r is even and gcd (b,ai)l(t-1), then k is the quasi-order of t mo(lulo b.Our Notice that the P-algorithm is really very easy to execute by hand, even without the use of a calculator.The W-algorithm is, however, more mechanical.Notice, too, that, in executing the -algorithm we are concerned with the residues mod t, while our conclusions are concerned with residues mod b. We close wih two "classical" applications of our algorithm in case t 2; of course, as explained in Remark (a) of Section 3, it is then unnecessary to display the c i, since they are always i. First the symbol 111 3 5 9 7 23 2 2 4 shows that the quasi-order of 2 mod 23 is 11 and that 2 Ii Mersenne number 2 is not prime.
Finally, the coup de  shows that the quasi-order of 2 mod 641 is 32 and that 2 m-1 mod 641.Thus the Fermat number 225 + is not prime.(Incidentally, as explained in [HP3], the symbol contains the information from which the complementary factor 6,700,417 may be derived the calculation should take about 31/2 minutes by hand!) Added in proof The interest in this problem among computer scientists is attested Dy the reference [5].
the strict period of the cycle.Then we may write a t-symbol (al, i 0 or k]._> i, and Ti is constrained as in(I.2)