Perfect numbers: Difference between revisions
Content deleted Content added
Remove unnecessary iteration and logically redundant test (if [sum == 2 * num] then [sum - num == num] for all positive num anyway). |
m Added wp ref and fixed definition - see discussion |
||
Line 1: | Line 1: | ||
{{task|Discrete math}}Write a function which says whether a number is perfect. |
{{task|Discrete math}}Write a function which says whether a number is perfect. |
||
A number is |
[[wp:Perfect_numbers|A perfect number]] is a positive integer that is the sum of its proper positive divisors excluding the number itself. Equivalently, a perfect number is a number that is half the sum of all of its positive divisors (including itself). |
||
Note: The faster [[Lucas-Lehmer test]] is used to find primes of the form 2<sup>''n''</sup>-1, all ''known'' perfect numbers can be derived from these primes using the formula (2<sup>''n''</sup> - 1) × 2<sup>''n'' - 1</sup>. It is not known if there are any odd perfect numbers. |
Note: The faster [[Lucas-Lehmer test]] is used to find primes of the form 2<sup>''n''</sup>-1, all ''known'' perfect numbers can be derived from these primes using the formula (2<sup>''n''</sup> - 1) × 2<sup>''n'' - 1</sup>. It is not known if there are any odd perfect numbers. |