Skip to content

Instantly share code, notes, and snippets.

@ramntry
Created November 1, 2014 20:02
Show Gist options
  • Select an option

  • Save ramntry/14ad433612f43b606bf7 to your computer and use it in GitHub Desktop.

Select an option

Save ramntry/14ad433612f43b606bf7 to your computer and use it in GitHub Desktop.
import Data.List
ham :: [Integer]
ham = 1 : (map head . group $ merge (map (* 3) ham) (map (* 10) ham)) where
merge l1@(x : xs) l2@(y : ys) | x < y = x : merge xs l2
| otherwise = y : merge l1 ys
main :: IO ()
main = do
num' <- getLine
putStrLn $ show $ ham !! read num'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment