Overview
The Perfect Numbers Explorer searches for perfect numbers - numbers where the sum of all proper divisors equals the number itself. All divisor calculations are performed using Romasm assembly.
Perfect Numbers
What are they?
A perfect number is a positive integer that equals the sum of its proper divisors (divisors excluding the number itself).
Examples:
- 6: Divisors are 1, 2, 3. Sum = 1 + 2 + 3 = 6 ✓
- 28: Divisors are 1, 2, 4, 7, 14. Sum = 1 + 2 + 4 + 7 + 14 = 28 ✓
- 496: Divisors sum to 496 ✓
- 8128: Divisors sum to 8128 ✓
Status: All known perfect numbers are even. It is unknown if any odd perfect numbers exist.
Romasm Implementation
The explorer uses Romasm assembly to find divisors and check if a number is perfect:
; Check if a number is perfect
; Input: R0 = number to check
; Output: R0 = 1 if perfect, 0 if not
LOAD R1, 1 ; Start with divisor = 1
LOAD R2, 0 ; Sum of divisors
LOAD R3, R0 ; Store original number
find_divisors:
; Check if R1 divides R0
MOD R4, R0, R1 ; R4 = R0 % R1
CMP R4, 0
JNE next_divisor
; R1 is a divisor, add to sum
ADD R2, R1 ; sum += divisor
next_divisor:
INC R1
; Only check up to n/2
LOAD R4, R0
LOAD R5, 2
DIV R4, R5 ; R4 = n/2
CMP R1, R4
JLE find_divisors
; Check if sum equals original number
CMP R2, R3
JEQ is_perfect
; Not perfect
LOAD R0, 0
RET
is_perfect:
LOAD R0, 1
RET
Using the Explorer
- Enter a number to check (or let it search automatically)
- Click "Check if Perfect"
- View all divisors found
- See the sum of divisors and verification
Related Documentation
- Try the Explorer - Open it now!