input: Write a function to find the largest prime factor of a given number. If the number is 1, return 1. If the number is negative or zero, return -1.
  assert largest_prime_factor(331)==331
  assert largest_prime_factor(13195)==29
  assert largest_prime_factor(600851475143)==6857
  assert largest_prime_factor(1)==1
  assert largest_prime_factor(-5)==-1
output: def largest_prime_factor(n):
      if n <= 0:
          return -1
      if n == 1:
          return 1
      largest_factor = -1
      while n % 2 == 0:
          largest_factor = 2
          n //= 2
      for i in range(3, int(n**0.5) + 1, 2):
          while n % i == 0:
              largest_factor = i
              n //= i
      if n > 2:
          largest_factor = n
      return largest_factor