[Math] How to check for perfect numbers

closed-formelementary-number-theorynumber theoryperfect numbers

To quote Wikipedia :

In number theory, a perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself (also known as its aliquot sum). Equivalently, a perfect number is a number that is half the sum of all of its positive divisors (including itself) i.e. $\sigma_1(n) = 2n$.

So one can easily define an algorithm to check for perfect numbers :

Let the number be $N$. We take an iteration from $i=1$ to $i=(N-1)$. If any particular $i $ satisfies $N \, mod\,\, i=0$ , then it is added to some variable say $S$, which is $0$ to begin with. At last, if $S = N$ , then $N$ is a perfect number.

This process is very lengthy and sometimes tedious.

Is there any faster way to check if a number is perfect? Is there any result in Number Theory related to checking Perfect Numbers? Is there any "general formula" / "closed form" for perfect numbers ?

Thanks in advance ! 🙂

Best Answer

Let $\mathbb{P}$ the set of all prime numbers.

It can be shown that if $2^p-1\in\mathbb{P}$ (which implies that $p\in\mathbb{P}$), then $2^{p-1}(2^p-1)$ is perfect. This was proved by Euclid (and those numbers are sometime called Euclid's numbers).

Conversely, any even perfect number is an Euclid's number : this was proved about 20 centuries later by Euler.

Until today, no odd perfect number is known ...

So detecting even perfect numbers is closely related to the question of detecting Mersenne primes (that is : primes of the form $2^p-1$).

A fast algorithm exists for this : it's called the Luca's test (see here)

It should also be worth looking at this site

Related Question