input: Write a function to find the largest prime factor of a number. If the given number is 1 then return 1.
  assert largest_prime_factor(331)==331
  assert largest_prime_factor(100)==5
  assert largest_prime_factor(1)==1
  assert largest_prime_factor(999001)==999001
  assert largest_prime_factor(207)==23
output: def largest_prime_factor(n):
      if n == 1:
          return 1
      largest = 1
      factor = 2
      while factor * factor <= n:
          while (n % factor) == 0:
              largest = factor
              n //= factor
          factor += 1
      if n > 1:
          largest = n
      return largest