input: Write a function to find the largest prime factor of a given number. If the number is negative or zero, return 0. If the number is 1, return 1.
  assert largest_prime_factor(331)==331
  assert largest_prime_factor(100)==5
  assert largest_prime_factor(-331)==0
  assert largest_prime_factor(1)==1
  assert largest_prime_factor(27)==3
output: def largest_prime_factor(n):
      if n <= 0:
          return 0
      if n == 1:
          return 1
      largest = 1
      if n % 2 == 0:
          largest = 2
          while n % 2 == 0:
              n //= 2
      factor = 3
      while factor * factor <= n:
          if n % factor == 0:
              largest = factor
              while n % factor == 0:
                  n //= factor
          factor += 2
      if n > 1:
          largest = n
      return largest