- 1
- 2
- 3
- 4
- 5
- 6
happy_numbers = [ tos (a,b,c,d,e,f a b c d e) | a <- [0..9], b <- [0..9], c <- [0..9], d <- [0..9], e <- [0..9], f a b c d e <= 9, f a b c d e >= 0 ]
where
tos (a,b,c,d,e,f) = show a ++ show b ++ show c ++ show d ++ show e ++ show f
f a b c d e = a + b + c - d - e
main = mapM print $ happy_numbers
Follow us!