input: Write a function to find the largest prime factor of a given number. If the given number is less than 2, return -1. If the given number is a prime number, return the number itself.
  assert largest_prime_factor(331)==331
  assert largest_prime_factor(100)==5
  assert largest_prime_factor(60)==5
  assert largest_prime_factor(1)==-1
  assert largest_prime_factor(2)==2
output: def largest_prime_factor(n):
      if n < 2:
          return -1
      def is_prime(num):
          if num <= 1:
              return False
          for i in range(2, int(num**0.5) + 1):
              if num % i == 0:
                  return False
          return True
      if is_prime(n):
          return n
      largest_factor = 1
      for i in range(2, int(n**0.5) + 1):
          while n % i == 0:
              largest_factor = i
              n //= i
      if n > 1:
          largest_factor = n
      return largest_factor