Modular numbers
FiniteFields.Modulo — Module
This module introduces modular arithmetic. It has no dependencies.
The integer x mod. n is constructed by the function Mod(x,n). If n isa Int the result is of type Mod{UInt64}. If n isa BigInt the result is of type Mod{BigInt}. Since n is not encoded in the type, the elements 0 and 1 mod. n cannot be constructed from the type, which causes some problems for some Julia functionality (for instance inv on a matrix does not work). For prime moduli p, the type FFE{p} in FiniteFields does not have such limitations.
Example:
julia> a=Mod(3,20)
Mod{UInt64}: 3₂₀
julia> a^2
Mod{UInt64}: 9₂₀
julia> inv(a) # need to be invertible mod. 20
Mod{UInt64}: 7₂₀
julia> a*inv(a)
Mod{UInt64}: 1₂₀
julia> a+2
Mod{UInt64}: 5₂₀
julia> a*2
Mod{UInt64}: 6₂₀
julia> a+1//3 # the denominator of the fraction needs to be inveritble mod. 20
Mod{UInt64}: 10₂₀
julia> Integer(a) # get back an integer from a
3
julia> order(a) # multiplicative order of a
4
julia> a^4
Mod{UInt64}: 1₂₀