import System.Environment

sieve :: Integer -> [Integer]
sieve n = takeWhile lessThan (till n)

    where lessThan x = x<=n
          
          till n = removeUntil (intSqrt n) [2..]
          
          intSqrt x
            | x <=0 = 0
            | otherwise = maximum $ takeWhile square [1..x]
            where square y = y*y <= x

          removeUntil num list = tailremoveUntil num [] list

          tailremoveUntil num header rest@(x:xs)
            | num >= x = tailremoveUntil num (x:header) (removeMults x xs)
            | otherwise = (reverse header) ++ rest

          removeMults x xs = filter (notMultipleOf x) xs

          notMultipleOf x = \y -> (y `mod` x) /= 0

main = do
    args <- getArgs
    let n = (read $ head args) :: Integer
    mapM putStrLn (map show (sieve n))
