Perfect numbers have fascinated mathematicians since ancient Greece. The Perfect Number Checker API determines if a number is perfect (proper divisors sum to itself), abundant, or deficient, with detailed divisor analysis.
What are Perfect Numbers?
A perfect number equals the sum of its proper divisors (all divisors except itself). The ancient Greeks considered these numbers special and connected them to harmony and completeness.
Example: 6 is perfect because 1 + 2 + 3 = 6. The proper divisors of 6 are 1, 2, and 3.
The known perfect numbers are: 6, 28, 496, 8128, 33550336... They are extremely rare!
Number Classifications
| Type | Definition | Example |
|---|---|---|
| Perfect | Proper divisors sum equals the number | 28 (1+2+4+7+14=28) |
| Abundant | Proper divisors sum exceeds the number | 12 (1+2+3+4+6=16 > 12) |
| Deficient | Proper divisors sum is less than the number | 10 (1+2+5=8 < 10) |
Using the Perfect Number Checker API
TinyFn provides a comprehensive endpoint for number classification:
GET https://api.tinyfn.io/v1/math/perfect-number?number=28
Headers: X-API-Key: your-api-key
{
"number": 28,
"classification": "perfect",
"is_perfect": true,
"is_abundant": false,
"is_deficient": false,
"proper_divisors": [1, 2, 4, 7, 14],
"proper_divisors_sum": 28,
"abundance": 0
}
Parameters
| Parameter | Type | Description |
|---|---|---|
number |
integer | The number to classify (required, 1 to 10^12) |
include_divisors |
boolean | Include list of proper divisors (default: true) |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/math/perfect-number?number=496',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const data = await response.json();
if (data.is_perfect) {
console.log(`${data.number} is a perfect number!`);
console.log(`Divisors: ${data.proper_divisors.join(' + ')} = ${data.proper_divisors_sum}`);
}
Python
import requests
# Check multiple numbers
for n in [6, 12, 28, 100]:
response = requests.get(
'https://api.tinyfn.io/v1/math/perfect-number',
headers={'X-API-Key': 'your-api-key'},
params={'number': n}
)
data = response.json()
print(f"{n}: {data['classification']}")
cURL
curl "https://api.tinyfn.io/v1/math/perfect-number?number=8128" \
-H "X-API-Key: your-api-key"
Common Use Cases
- Educational Tools: Teach number theory concepts
- Math Puzzles: Programming challenges like Project Euler
- Number Classification: Categorize numbers in datasets
- Research Tools: Study number properties and patterns
- Mathematical Art: Generate number sequences for visualizations
Best Practices
- Know the rarity: Perfect numbers are extremely rare - don't expect to find many
- Use abundance value: Positive = abundant, negative = deficient, zero = perfect
- Cache known perfects: Only a few perfect numbers fit in standard integer types
- Handle large numbers: Divisor calculation can be intensive for large inputs
- Explore patterns: All even perfect numbers have the form 2^(p-1)(2^p-1) where 2^p-1 is prime
Use via MCP
Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:
{
"mcpServers": {
"tinyfn-math": {
"url": "https://api.tinyfn.io/mcp/math/",
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}
See all math tools available via MCP in our Math MCP Tools for AI Agents guide.
Try the Perfect Number Checker API
Get your free API key and start exploring perfect numbers.
Get Free API Key