Algosim documentation: totient

totient

Euler’s totient (phi) function.

Syntax

Description

If n is a positive integer, then totient(n) is the number of positive integers less than or equal to n that are relatively prime to n.

Notes

If you use the totient function frequently, you may want to assign it to the φ symbol:

φ ≔ totient

Examples

totient(19871226)
6200064
φ ≔ totient; n ≔ 123456; ∑(divisors(n) @ φ)
123456

See also