Comment Get the value for N
Output: "Please enter a positive integer: "
Input: N
If N <= 0 Then
Output: N " isn't a perfect number."
STOP
Endif
Comment Initialize sum of the divisors & divison
SumOfDivisors <-- 1
Candidate <-- 2
Comment Consider all possible divisors
While Candidate <= N / 2 Do
R <-- N - (Truncate ( N / Candidate ) )* Candidate
If R = 0 Then
SumOfDivisors <-- SumOfDivisors + Candidate
Candidate <-- Candidate + 1
Endwhile
Comment Check the results
If SumOfDivisors = N Then
Output: N " is a perfect number."
Else