perfect_numbers_in_range(start, end) that returns a list of all perfect numbers between start and end inclusive. A perfect number equals the sum of its proper divisors (divisors excluding itself), for example 6 = 1 + 2 + 3. Use nested loops: an outer loop over candidates and an inner loop to sum divisors.perfect_numbers_in_range(1, 30)
[6, 28]
6 and 28 are the only perfect numbers in that range.
perfect_numbers_in_range(1, 5)
[]
No perfect numbers that small.
For each candidate number, sum all divisors from 1 up to candidate - 1 that evenly divide it.
A candidate is perfect if that sum equals the candidate itself (and the candidate is greater than 0).