S-99を解く。互いに素かどうか判定する問題と、それをつかってオイラーのφ関数を求める
class IntWrapper(n:scala.Int){ def gcd(a:scala.Int, b:scala.Int): scala.Int = if (b == 0) a else gcd(b, a % b) def isCoprimeTo(i:scala.Int): Boolean = gcd(n,i) == 1 def totient: scala.Int = (1 to n) filter {(new IntWrapper(n)).isCoprimeTo(_)} length } implicit def int2IntWrapper(n:scala.Int) = new IntWrapper(n) println("s33: " + 35.isCoprimeTo(64)) println("s34: " + 10.totient)