summaryrefslogtreecommitdiff
path: root/gcd.hs
blob: c3261150413f7eb67a3469826d7ec7b828d52854 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import System(getArgs)

gcd2 a 0 = a
gcd2 a b = gcd2 b (rem b a)

gcdn n = foldl1 gcd2 n

str2int :: String -> Integer
str2int = read

main = do
    a <- getArgs
    print (gcdn (map str2int a))