input: Write a python function to generate prime numbers up to a given number n.
  assert generate_primes(10) == [1, 2, 3, 5, 7]
  assert generate_primes(20) == [1, 2, 3, 5, 7, 11, 13, 17, 19]
  assert generate_primes(5) == [1, 2, 3, 5]
output: def generate_primes(n):
      if n < 2:
          return [1]
      primes = [2]
      for num in range(3, n+1, 2):
          is_prime = True
          for prime in primes:
              if prime * prime > num:
                  break
              if num % prime == 0:
                  is_prime = False
                  break
          if is_prime:
              primes.append(num)
      return [1] + primes