Remove an extra division

Currently, GHC does not merge `div` with `mod` by itself; `divMod` saves time.

Turn nested `if`s into `case`.
Merge pull request #10 from treeowl/master

Remove an extra division