Created
March 21, 2016 17:57
-
-
Save Denommus/038b62f611d91c595206 to your computer and use it in GitHub Desktop.
List every trilegal number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trilegals :: [Int] | |
trilegals = filter isTrilegal [100..1000] | |
isTrilegal :: Int -> Bool | |
isTrilegal n | |
| n < 100 || n > 999 = False | |
| otherwise = u - d == (d - c)*3 | |
where [c, d, u] = map (read . (:"")) (show n) :: [Int] | |
main :: IO () | |
main = print trilegals |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment