libzahl

big integer library
git clone git://git.suckless.org/libzahl
Log | Files | Refs | README | LICENSE

commit 8092c767cb5f872b62a0cabbef793a08643497db
parent dd753f78b0c39d86a4cccca08996df303762e532
Author: Mattias Andrée <maandree@kth.se>
Date:   Thu, 28 Jul 2016 22:55:43 +0200

φ(−n) = φ(n), φ(1) = 1, φ(0) = 0

Signed-off-by: Mattias Andrée <maandree@kth.se>

Diffstat:
Mdoc/exercises.tex | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/doc/exercises.tex b/doc/exercises.tex @@ -262,10 +262,13 @@ which calculates the totient of $n$. Its formula is \( \displaystyle{ - \varphi(n) = n \prod_{p \in \textbf{P} : p | n} + \varphi(n) = |n| \prod_{p \in \textbf{P} : p | n} \left ( 1 - \frac{1}{p} \right ). }\) +Note that, $\varphi(-n) = \varphi(n)$, $\varphi(0) = 0$, +and $\varphi(1) = 1$. + \end{enumerate} @@ -671,7 +674,8 @@ So, if we set $a = n$ and $b = 1$, then we iterate of all integers $p$, $2 \le p \le n$. For which $p$ that is prime, we set $a \gets a \cdot (p - 1)$ and $b \gets b \cdot p$. After the iteration, $b | a$, -and $\varphi(n) = \frac{a}{b}$. +and $\varphi(n) = \frac{a}{b}$. However, if $n < 0$, +then, $\varphi(n) = \varphi|n|$.