Added factorisation class to Problem 5 solution.

Improved performance of Problem 5 solution by reducing redundant checks. Further improvements are probably possible.

Signed-off-by: Ephphatha <ephphatha@thelettereph.com>