input: Write a function to find the largest prime factor of a given number. Return the largest prime factor found. If the number is prime, return the number itself. If the number is less than 2, return None.
  def largest_prime_factor(n):
      if n < 2:
          return None
      factors = []
      for i in range(2, int(math.sqrt(n)) + 1):
          if n % i == 0:
              factors.append(i)
              factors.append(int(n/i))
      prime_factors = [f for f in factors if all(f % j != 0 for j in range(2, int(math.sqrt(f)) + 1)) or f == 2]
      if prime_factors:
          return max(prime_factors)
      else:
          return n
  
  assert largest_prime_factor(331)==331
  assert largest_prime_factor(24)==3
  assert largest_prime_factor(151)==151
  assert largest_prime_factor(432)==3
  assert largest_prime_factor(1)==None
output: def largest_prime_factor(n):
      if n < 2:
          return None
      factors = []
      for i in range(2, int(math.sqrt(n)) + 1):
          if n % i == 0:
              factors.append(i)
              factors.append(int(n/i))
      prime_factors = [f for f in factors if all(f % j != 0 for j in range(2, int(math.sqrt(f)) + 1)) or f == 2]
      if prime_factors:
          return max(prime_factors)
      else:
          return n