Your question is Perfect Number Program. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
A Luxoft India diagnostics utility needs to identify mathematically significant values in a range. Given two integers, return every perfect number between them, inclusive, in ascending order.
A positive integer is perfect when it equals the sum of its proper positive divisors, excluding the number itself. For example, 28 is perfect because 1 + 2 + 4 + 7 + 14 = 28.
Implement perfect_numbers(left, right).
left and right, representing an inclusive range. Assume left <= right.[left, right], sorted in ascending order. Return an empty list when the range contains none.For each candidate, calculate its proper-divisor sum efficiently. Do not test every possible divisor up to the candidate when a square-root divisor-pair approach can be used.
def perfect_numbers(left, right):