summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Zhao <ztuowen@gmail.com>2015-04-01 10:49:49 +0800
committerJoe Zhao <ztuowen@gmail.com>2015-04-01 10:49:49 +0800
commit3eec84838808139470261893ce15846852384bcf (patch)
tree6c293d04f7c6f913da8fd06f215b7b6547de8105
parenta9abc1da41b56edbed00081800382e854d6698d0 (diff)
downloadh99-3eec84838808139470261893ce15846852384bcf.tar.gz
h99-3eec84838808139470261893ce15846852384bcf.tar.bz2
h99-3eec84838808139470261893ce15846852384bcf.zip
+37 +38
-rw-r--r--H34.hs3
-rw-r--r--H36.hs5
-rw-r--r--H37.hs5
-rw-r--r--H38.hs4
4 files changed, 16 insertions, 1 deletions
diff --git a/H34.hs b/H34.hs
index 6db5e5d..6cbbdad 100644
--- a/H34.hs
+++ b/H34.hs
@@ -1,3 +1,4 @@
-- http://en.wikipedia.org/wiki/Euler%27s_totient_function
-totient :: Integral a => a -> Bool
+
+totient :: (Integral a) => a -> Int
totient x = length $ filter ((==1).(gcd x)) [1..x]
diff --git a/H36.hs b/H36.hs
index 3cd36eb..71868d9 100644
--- a/H36.hs
+++ b/H36.hs
@@ -1,3 +1,8 @@
+module H36
+(
+ primeFactorsMult
+) where
+
import H35
import H10
diff --git a/H37.hs b/H37.hs
new file mode 100644
index 0000000..d5c07f5
--- /dev/null
+++ b/H37.hs
@@ -0,0 +1,5 @@
+import H36
+
+toitient :: Integer -> Integer
+toitient n = foldr (\(y,_) x -> x * (y-1) `div` y) n (primeFactorsMult n)
+
diff --git a/H38.hs b/H38.hs
new file mode 100644
index 0000000..312ef8a
--- /dev/null
+++ b/H38.hs
@@ -0,0 +1,4 @@
+-- Measure performance with GHC
+-- https://wiki.haskell.org/Performance/GHC#Measuring_performance
+
+-- In ghci :set +s will output the time consumption for every command