Problem 50182. Compute the Euler totient function

The Euler totient function phi(n) gives the number of integers smaller than n that are relatively prime to n---that is, that share no common factors with n other than 1. For example, phi(12) = 4 because 1, 5, 7, and 11 share no common factors other than 1. If p is a prime number, then phi(p) = p-1 because all numbers smaller than p are relatively prime to p.
Write a function to compute the Euler totient function.
Note: I now realize that Cody Problem 656 also deals with the totient function. Apologies to Freddy.

Solution Stats

47.62% Correct | 52.38% Incorrect
Last Solution submitted on Nov 24, 2021

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers9

Suggested Problems

More from this Author279

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!