Skip to content

A C-based computational tool that validates whether a given integer is a 'Perfect Number' by calculating the sum of its proper positive divisors.

License

Notifications You must be signed in to change notification settings

ShotsMan2/Perfect-Number-Validator-Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Perfect Number Validator

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.

🧮 Mathematical Definition

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 $n$ is perfect if: $$\sigma_{1}(n) - n = n$$ Where $\sigma_{1}(n)$ is the sum of all positive divisors of $n$.

Example Case

For the integer 6:

  • Divisors: 1, 2, 3
  • Sum: $1 + 2 + 3 = 6$
  • Result: ✅ Perfect Number

⚙️ Technical Implementation

  • Language: C (Standard Library)
  • Logic: Linear Iteration ($O(n)$ complexity).
  • Process:
    1. Accepts integer input.
    2. Iterates from $1$ to $n-1$.
    3. Accumulates factors where $n \pmod i \equiv 0$.
    4. Compares the accumulator to the original input.

🚀 How to Run

  1. Compile the code:
    gcc main.c -o validator
  2. Run the executable:
    ./validator

This repository demonstrates algorithmic implementation of mathematical properties using C.

About

A C-based computational tool that validates whether a given integer is a 'Perfect Number' by calculating the sum of its proper positive divisors.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages