99 Elm Problems/Problem 37
Jump to navigation
Jump to search
Calculate Euler's totient function phi(m) (improved).See problem 34 for the definition of Euler's totient function. If the list of the prime factors of a number m is known in the form of problem 36 then the function phi(m) can be efficiently calculated as follows: Let ((p1 m1) (p2 m2) (p3 m3) ...) be the list of prime factors (and their multiplicities) of a given number m. Then phi(m) can be calculated with the following formula:
# # # THIS IS A STUB # # #
Example in Elm:
import Html exposing (text)
import List
f : Int -> Int
-- your implementation goes here
main = text (toString (f 0))
Result:
4