This project implements an algorithmic check in C to determine if a user-inputted integer classifies as a Perfect Number according to number theory principles.
In number theory, a perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself.
Formally, a number
For the integer 6:
- Divisors: 1, 2, 3
-
Sum:
$1 + 2 + 3 = 6$ - Result: ✅ Perfect Number
- Language: C (Standard Library)
-
Logic: Linear Iteration (
$O(n)$ complexity). -
Process:
- Accepts integer input.
- Iterates from
$1$ to$n-1$ . - Accumulates factors where
$n \pmod i \equiv 0$ . - Compares the accumulator to the original input.
- Compile the code:
gcc main.c -o validator
- Run the executable:
./validator
This repository demonstrates algorithmic implementation of mathematical properties using C.