Perfect Number Checker API: Identify Perfect, Abundant, and Deficient Numbers

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)
Math Fact: All known perfect numbers are even. It's an open question whether odd perfect numbers exist - none have ever been found.

Using the Perfect Number Checker API

TinyFn provides a comprehensive endpoint for number classification:

API Request
GET https://api.tinyfn.io/v1/math/perfect-number?number=28
Headers: X-API-Key: your-api-key
Response
{
  "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

  1. Know the rarity: Perfect numbers are extremely rare - don't expect to find many
  2. Use abundance value: Positive = abundant, negative = deficient, zero = perfect
  3. Cache known perfects: Only a few perfect numbers fit in standard integer types
  4. Handle large numbers: Divisor calculation can be intensive for large inputs
  5. Explore patterns: All even perfect numbers have the form 2^(p-1)(2^p-1) where 2^p-1 is prime

Try the Perfect Number Checker API

Get your free API key and start exploring perfect numbers.

Get Free API Key

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key