How would you find the largest prime factor of a given number?
Given an integer n, implement the function below and return its largest prime factor. The input is an integer n >= 2, and the output must be an integer. Use an approach that avoids testing every value up to n when possible.
def largest_prime_factor(n):