From 3eec84838808139470261893ce15846852384bcf Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Wed, 1 Apr 2015 10:49:49 +0800 Subject: +37 +38 --- H34.hs | 3 ++- H36.hs | 5 +++++ H37.hs | 5 +++++ H38.hs | 4 ++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 H37.hs create mode 100644 H38.hs 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 -- cgit v1.2.3-70-g09d2