commands → totient

totient(n)

The totient command computes the number of integers less than n that are relatively prime to n. These numbers are all invertible modulo n.

Examples

totient(15);
	8

totient(24);
	8

Algorithm

The algorithm begins by factoring n.

References

Link to Handbook of Applied Cryptography