Convert to integer before printing

If the user enters `000`, the program now prints `0` instead of `000`.

Also, move functions only used in `main` into a `where` clause.