Skip to content

Instantly share code, notes, and snippets.

@takahisa
Created March 30, 2015 04:17
Show Gist options
  • Save takahisa/c81ff0263546e907bc56 to your computer and use it in GitHub Desktop.
Save takahisa/c81ff0263546e907bc56 to your computer and use it in GitHub Desktop.
Hamming
hamming :: [Int]
hamming = filter p [1..]
where
p :: Int -> Bool
p x | x `mod` 5 == 0 = p (x `div` 5)
| x `mod` 3 == 0 = p (x `div` 3)
| x `mod` 2 == 0 = p (x `div` 2)
| otherwise = x == 1
main :: IO ()
main = mapM_ print (take 30 hamming)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment