C problem 12: move functions to utils.
Haskell: move factor to utils.