1
2
3
4
5
6
7
8
9
10
11
12
module Main where
  import Control.Monad (mapM_)

  digs :: Int -> [Int]
  digs 0 = []
  digs x = x `mod` 10 : digs (x `div` 10)

  squareN n = n * n 

  printSquareOfEachDigit = mapM_ (putStrLn . show . squareN) . reverse . digs

  main = printSquareOfEachDigit 123456789