Euler’s totient function $\varphi$ counts the number of positive integers less than or equal to $n$ that are relatively prime (coprime) to $n$:

\begin{aligned} \forall n \in \mathbb{N}^*, \varphi(n) &=\operatorname{card}\{1\leqslant k\leqslant n \mid \operatorname{gcd}(k,n)=1\} \\ &=\sum_{k=1}^{n} [\gcd(k,n) = 1] \end{aligned}

## Example

$\varphi(7)=6=\operatorname{card}\{1\leqslant k\leqslant 6 \mid \operatorname{gcd}(k,6)=1\} =\operatorname{card}\{1,2,3,4,5,6\}$