logo

Orders in Number Theory 📂Number Theory

Orders in Number Theory

Definition 1

Theorem

If an1(modp)a^{n} \equiv 1 \pmod{p}, then ordp(a)n\text{ord}_{p} (a) \mid n.

Explanation

For example, consider p=7p=7. 111(mod7)231(mod7)361(mod7)431(mod7)561(mod7)621(mod7) \begin{align*} 1^{1} \equiv & 1 \pmod{ 7 } \\ 2^{3} \equiv & 1 \pmod{ 7 } \\ 3^{6} \equiv & 1 \pmod{ 7 } \\ 4^{3} \equiv & 1 \pmod{ 7 } \\ 5^{6} \equiv & 1 \pmod{ 7 } \\ 6^{2} \equiv & 1 \pmod{ 7 } \end{align*} Here, the order of 66 is 22, the order of 2,42, 4 is 33, and the order of 3,53,5 is 66.

Especially in the above theorem, if we set n=p1n=p-1, we can easily verify that 2,3,62,3,6 divides p1=6p-1= 6. Furthermore, according to Fermat’s Little Theorem, for a prime number pp, it always holds that ap11(modp)a^{p-1} \equiv 1 \pmod{p}, thus we know ordp(a)(p1)\text{ord}_{p} (a) \mid (p-1) is true.

Proof

If we set G:=gcd(ordp(a),n)G := \gcd ( \text{ord}_{p} (a) , n ), then there exists s,ts,t that satisfies G=ordp(a)s+ntG = \text{ord}_{p}(a) \cdot s + n \cdot t.

By the definition of order and by assumption, aG=aordp(a)s+nt=(aordp(a))s(an)t11(modp) a^{G} = a^{ \text{ord}_{p}(a) \cdot s + n \cdot t} = \left( a^{ \text{ord}_{p}(a) } \right)^s \cdot \left( a^{n} \right)^{t} \equiv 1 \cdot 1 \pmod{p} since ordp(a)\text{ord}_{p}(a) is defined as the smallest natural number ee that satisfies ae1(modp)a^{e} \equiv 1 \pmod{p}, it follows that G=ordp(a)G = \text{ord}_{p}(a) and, ordp(a)p\text{ord}_{p}(a) \mid p.

Code

Below is the code written in R language to compute the order. Prime factorization code was used.

prime = read.table("../attachment
                   /cfile8.uf@25411C3C5968BBE322F0D4.txt"); prime = prime[,1]
 
factorize<-function(p)
{
  q=p
  factors<-numeric(0)
  i=1; j=1
  while(q!=1)
  {
    if(q%%prime[i]) {i=i+1}
    else
    {
      q<-q/prime[i]
      factors[j]<-prime[i]
      i=1
      j=j+1
    }
  }
  return(factors)
}
 
order<-function(g,p,h=1) #Calculate a order of g in modulo p
{
  qe<-table(factorize(p-1))
  qe<-rbind(as.numeric(names(qe)),qe)
  divisor<-qe[1,1]^(0:qe[2,1])
  if((length(qe)/2)==1) {return(qe[1,1]^qe[2,1])}
  for(i in 2:(length(qe)/2)) {divisor=c(divisor%*%t(qe[1,i]^(0:qe[2,i])))}
  for(i in divisor) {if((FPM(g,i,p))%%p==1) break;}
  return(i)
}
 
order(1,7)
order(2,7)
order(3,7)
order(4,7)
order(5,7)
order(6,7)

Below is the result of executing the above code.

20190227\_095435.png


  1. Silverman. (2012). A Friendly Introduction to Number Theory (4th Edition): p211. Let us define gcd(a,p)=1\gcd (a, p) = 1. The smallest natural number ee that satisfies ae1(modp)a^{e} \equiv 1 \pmod{p} is denoted as ordp(a)\text{ord}_{p} (a), and is defined as the order of aa modulo pp↩︎