talc/examples/totient.talc
2024-10-31 17:20:20 -04:00

8 lines
142 B
Text

totient = \n -> do
count(factors(n)) | pairs | map(\v -> do
(v!0)^(v!1) - (v!0)^(v!1 - 1)
end) | prod
end
println(totient(6615)) -- 3024