Learn R Programming

primes (version 1.6.0)

phi: Euler's Totient Function

Description

Compute Euler's Totient Function (\(\phi(n)\)). Provides the count of \(k\) integers that are coprime with \(n\) such that \(1 \le k \le n\) and \(gcd(n,k) = 1\).

Usage

phi(n)

Value

An integer vector.

Arguments

n

an integer vector.

Author

Paul Egeler, MS

References

"Euler's totient function" (2020) Wikipedia. https://en.wikipedia.org/wiki/Euler%27s_totient_function (Accessed 21 Aug 2020).

See Also

gcd, coprime, prime_factors

Examples

Run this code
phi(12)
## [1] 4

phi(c(9, 10, 142))
## [1]  6  4 70

Run the code above in your browser using DataLab