input: Write a python function to convert a given integer to a specified base.
  assert base_n(10, 2) == '1010'
  assert base_n(255, 16) == 'FF'
  assert base_n(7, 3) == '21'
output: def base_n(num, base):
      if base < 2 or base > 36:
          raise ValueError("Base must be between 2 and 36")
      
      digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
      if num == 0:
          return "0"
      
      result = ""
      while num:
          result = digits[num % base] + result
          num //= base
      
      return result