input: Write a python function to sum all prime numbers up to a given limit.
  assert sum_primes(10) == 17
  assert sum_primes(20) == 77
  assert sum_primes(30) == 129
output: def sum_primes(limit):
      def is_prime(n):
          if n <= 1:
              return False
          if n == 2:
              return True
          if n % 2 == 0:
              return False
          max_divisor = int(n**0.5) + 1
          for d in range(3, max_divisor, 2):
              if n % d == 0:
                  return False
          return True
      
      return sum(n for n in range(2, limit+1) if is_prime(n))