0

Explain this code

a=6; Roots=[x for x in range(1,a) if a%x==0]; Print(sum(roots)==a and a>0; #Output True

9th Jul 2020, 5:57 AM
Emon
2 Answers
0
Roots is the list of all the divisors of a. The code checks if a is a Perfect Number (a Perfect Number is a positive number, where the sum of all its positive divisors is equal to the number itself). By the way, 6 is the first perfect number, and only 51 perfect numbers are known, all of them even numbers.
9th Jul 2020, 6:10 AM
Bilbo Baggins
Bilbo Baggins - avatar