diff options
author | Joe Zhao <ztuowen@gmail.com> | 2015-04-01 10:49:49 +0800 |
---|---|---|
committer | Joe Zhao <ztuowen@gmail.com> | 2015-04-01 10:49:49 +0800 |
commit | 3eec84838808139470261893ce15846852384bcf (patch) | |
tree | 6c293d04f7c6f913da8fd06f215b7b6547de8105 | |
parent | a9abc1da41b56edbed00081800382e854d6698d0 (diff) | |
download | h99-3eec84838808139470261893ce15846852384bcf.tar.gz h99-3eec84838808139470261893ce15846852384bcf.tar.bz2 h99-3eec84838808139470261893ce15846852384bcf.zip |
+37 +38
-rw-r--r-- | H34.hs | 3 | ||||
-rw-r--r-- | H36.hs | 5 | ||||
-rw-r--r-- | H37.hs | 5 | ||||
-rw-r--r-- | H38.hs | 4 |
4 files changed, 16 insertions, 1 deletions
@@ -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] @@ -1,3 +1,8 @@ +module H36 +( + primeFactorsMult +) where + import H35 import H10 @@ -0,0 +1,5 @@ +import H36 + +toitient :: Integer -> Integer +toitient n = foldr (\(y,_) x -> x * (y-1) `div` y) n (primeFactorsMult n) + @@ -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 |