summaryrefslogtreecommitdiff
path: root/gcd.hs
blob: 764e8246b48109f48c5e5cabcb144d119ebd8542 (plain)
1
2
3
4
5
6
7
8
9
10
11
import Control.Monad.Writer

gcd' :: Int -> Int -> Writer [String] Int
gcd' a b
    | b == 0 = do
        tell ["Finished with " ++ show a]
        return a
    | otherwise = do
        tell [show a ++ " mod " ++ show b ++ " = " ++ show (a `mod` b)]
        gcd' b (a `mod` b)