commands → order

order(A,N)

The order command computes the order of an element modulo N, that is, the smallest integer X with A^X = 1 mod N. If there is no such X then null is returned.

Examples

order(2,5);
	4

(2^4) % 5;
	1

Algorithm

The algorithm factors the totient and removes divisors.

References

Link to Handbook of Applied Cryptography