summaryrefslogtreecommitdiff
path: root/31-41/34.hs
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2017-05-29 13:29:11 -0400
committerDeterminant <ted.sybil@gmail.com>2017-05-29 13:29:11 -0400
commit9db0008777cc4cd9f07e14a3458e3d903e3cc4f6 (patch)
treeaf3891261924ae914ee3855e948b4d479f4d06de /31-41/34.hs
parentfa1bf6c2eac1c9f7969ff29504c9f51b9ba48008 (diff)
finish vol 4
Diffstat (limited to '31-41/34.hs')
-rw-r--r--31-41/34.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/31-41/34.hs b/31-41/34.hs
new file mode 100644
index 0000000..fe542a2
--- /dev/null
+++ b/31-41/34.hs
@@ -0,0 +1,11 @@
+import Data.List (foldl')
+
+myGCD :: Int -> Int -> Int
+
+
+myGCD a 0 = abs a
+myGCD a b = myGCD b (a `mod` b)
+
+totient :: Int -> Int
+
+totient x = foldl' (\acc y -> acc + if myGCD x y == 1 then 1 else 0) 0 [1..x]