NTLib - Number Theory Library 0.9
Loading...
Searching...
No Matches
euler_totient Module Reference

Compute Euler's totient function \(\phi\). More...

Functions

template<Integer T>
constexpr T ntlib::euler_totient (const prime_factors< T > &factors) noexcept
 Computes Euler's totient function \(\phi(n)\) for a given number n.
template<Integer T>
constexpr T ntlib::euler_totient (T n) noexcept
 Computes Euler's totient function \(\phi(n)\) for a given number.
template<Integer T>
std::vector< T > ntlib::euler_totient_sieve (std::size_t N)
 Computes Euler's totient function \(\phi(n)\) for all integers up to a given number N.

Detailed Description

Compute Euler's totient function \(\phi\).

Euler's totient function counts the number of integers up to n that are coprime to n.

The module provides function templates to compute Euler's totient function \(\phi\). Both, to compute \(\phi(n)\) for a single number \(n\) or by using a sieve for all \(n \leq N\).

Files

file  modules/arithmetic_functions/euler_totient.cpp
 Primary module interfact unit for module euler_totient.