// P34 (**) Calculate Euler's totient function phi(m). // Euler's so-called totient function phi(m) is defined as the number of // positive integers r (1 <= r < m) that are coprime to m. As a special // case, phi(1) is defined to be 1. // // scala> 10.totient // res0: Int = 4 class S99Int(val start: Int) { def totient: Int = (1 to start) filter { start.isCoprimeTo(_) } length }