euclid :: Int -> Int
euclid n = length (filter (gcd n == 1) [1 .. n-1])
gcd :: Int -> Int -> Int
..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you’re looking for Euler’s totient function, simply call
The linked WP article gives a formula for calculating this directly:
You’ll need a
factorizefunction for that:Next optimization is to use primes list instead of
(2:[3,5..]).