Factorisation example written in C++