import Numeric(showIntAtBase)
import Data.Char(ord, chr)
digitToChar n | n < 10 = chr $ n + ord '0'
| n < 36 = chr $ (n - 10) + ord 'a'
| n == 36 = 'A'
base10to37 n = showIntAtBase 37 digitToChar n ""
main = interact $ unlines . map (base10to37 . read) . lines
Note that non-ascii characters in the above source code will be escaped (such as \x9f).