talc/examples/totient.talc

8 lines
142 B
Text
Raw Normal View History

2024-10-31 21:20:20 +00:00
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