Finding largest prime factor was taking ages with previous solution. Refactored with code from StackOverflow (LOL)