Implemented Lopatin's algorithm for factorisation