An algorithm to calculate the largest prime factor of a number.