We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 60f63c1 commit 22d3182Copy full SHA for 22d3182
chapter04-Defining-functions/8.hs
@@ -0,0 +1,9 @@
1
+luhnDouble :: Int -> Int
2
+luhnDouble n | d > 9 = d - 9
3
+ | otherwise = d
4
+ where d = n * 2
5
+
6
+luhn :: Int -> Int -> Int -> Int -> Bool
7
+luhn n1 n2 n3 n4 | sum `mod` 10 == 0 = True
8
+ | otherwise = False
9
+ where sum = luhnDouble n1 + n2 + luhnDouble n3 + n4
0 commit comments