eulersPhi(9973) == 9973 - 1 # for prime numbers
eulersPhi(3^10) == 3^9 * (3 - 1) # for prime powers
eulersPhi(12*35) == eulersPhi(12) * eulersPhi(35) # TRUE if coprime
if (FALSE) {
x <- 1:100; y <- sapply(x, eulersPhi)
plot(1:100, y, type="l", col="blue",
xlab="n", ylab="phi(n)", main="Euler's totient function")
points(1:100, y, col="blue", pch=20)
grid()}
Run the code above in your browser using DataLab