Algorithm for calculation of Lowest Common Multiple