Skip to content

Commit 5da0f8b

Browse files
committed
Fix function in chapter 5 exercises, closes #1
1 parent 0a8cdf6 commit 5da0f8b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

05-list-comprehensions/05.7-exercises.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ factors :: Int -> [Int]
2727
factors n = [x | x <- [1..n], n `mod` x == 0]
2828

2929
perfects :: Int -> [Int]
30-
perfects n = [sum (factors x) | x <- [1..n]]
30+
perfects n = [x | x <- [1..n], sum (factors x) - x == x]
3131

3232
-- 7.
3333
-- Show how the list comprehension [(x, y) | x <- [1, 2], y <- [3, 4]] with two generators can be

0 commit comments

Comments
 (0)