input: Write a function to find perfect numbers up to a given number.
  assert perfect_numbers(30) == [6, 28]
  assert perfect_numbers(100) == [6, 28]
  assert perfect_numbers(500) == [6, 28, 496]
output: def perfect_numbers(n):
      def is_perfect(num):
          return num == sum(i for i in range(1, num) if num % i == 0)
      
      return [x for x in range(1, n+1) if is_perfect(x)]