Orders in Number Theory
Definition 1
Theorem
If , then .
Explanation
For example, consider . Here, the order of is , the order of is , and the order of is .
Especially in the above theorem, if we set , we can easily verify that divides . Furthermore, according to Fermat’s Little Theorem, for a prime number , it always holds that , thus we know is true.
Proof
If we set , then there exists that satisfies .
By the definition of order and by assumption, since is defined as the smallest natural number that satisfies , it follows that and, .
■
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.
Silverman. (2012). A Friendly Introduction to Number Theory (4th Edition): p211. Let us define . The smallest natural number that satisfies is denoted as , and is defined as the order of modulo . ↩︎