;;; Euler's totient function phi(m) is defined as the number
;;; of positive integers r (1 <= r <= m) that are coprime to m.
(defun phi (m)
(if (< 0 m)
(phi-aux 1 m)
'undef
)
)
;;; Function phi-aux(k,m) is defined as the number
;;; of positive integers r (k <= r < m) that are coprime to m.
(defun phi-aux (k m)
(if (<= k m)
(+ (phi-aux (1+ k) m)
(if (coprime k m) 1 0)
)
0
)
)