input: Write a function to find the largest prime factor of a given number. If the input number is 1, return 1.
  assert largest_prime_factor(331) == 331
  assert largest_prime_factor(29) == 29
  assert largest_prime_factor(1) == 1
  assert largest_prime_factor(257) == 257
  assert largest_prime_factor(684) == 19
output: def largest_prime_factor(n):
      if n == 1:
          return 1
      factor = 2
      while factor * factor <= n:
          if n % factor == 0:
              n //= factor
          else:
              factor += 1
      return n