P34: Calculate Euler's totient function phi(m)

整数mに対しcoprimeである整数r (1 <= r < m)の数を返す関数phiを作る。

P33の結果を使い、直接的に実装。
もっとスマートな方法は、後の問題で議論するらしい。

;; P34
(defun totient-phi (m)
  (do ((result 0 (if (or (= n 1) (coprime m n))
		     (1+ result)
		     result))
       (n m (1- n)))
      ((< n 1) result)))

(totient-phi 10)
;; => 4
(totient-phi 11)
;; => 10