Need to find all the divisors of a number? The Divisors API returns every number that divides evenly into your input, along with useful statistics like divisor count, sum, and proper divisors.
What are Divisors?
A divisor (or factor) of a number n is any integer that divides n evenly (with no remainder). For example, the divisors of 12 are 1, 2, 3, 4, 6, and 12.
Every positive integer n has at least two divisors: 1 and n itself. Prime numbers have exactly two divisors.
Types of Divisors
The API returns several divisor categories:
All Divisors
Complete list of numbers that divide evenly into n
Proper Divisors
All divisors except the number itself (used for perfect number detection)
Divisor Count
Total number of divisors (also called tau function or d(n))
Divisor Sum
Sum of all divisors (also called sigma function or sigma(n))
Using the Divisors API
TinyFn provides a comprehensive endpoint for finding divisors:
GET https://api.tinyfn.io/v1/math/divisors?number=28
Headers: X-API-Key: your-api-key
{
"number": 28,
"divisors": [1, 2, 4, 7, 14, 28],
"proper_divisors": [1, 2, 4, 7, 14],
"count": 6,
"sum": 56,
"proper_sum": 28,
"is_prime": false,
"is_perfect": true
}
Parameters
| Parameter | Type | Description |
|---|---|---|
number |
integer | The number to find divisors for (required, 1 to 10^12) |
proper_only |
boolean | Return only proper divisors (default: false) |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/math/divisors?number=100',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const data = await response.json();
console.log(`Divisors of 100: ${data.divisors.join(', ')}`);
console.log(`Count: ${data.count}, Sum: ${data.sum}`);
Python
import requests
response = requests.get(
'https://api.tinyfn.io/v1/math/divisors',
headers={'X-API-Key': 'your-api-key'},
params={'number': 28}
)
data = response.json()
if data['is_perfect']:
print(f"{data['number']} is a perfect number!")
print(f"Proper divisors sum to: {data['proper_sum']}")
cURL
curl "https://api.tinyfn.io/v1/math/divisors?number=60" \
-H "X-API-Key: your-api-key"
Common Use Cases
- Perfect Number Detection: Check if numbers are perfect, abundant, or deficient
- GCD Calculation: Find common divisors of multiple numbers
- Educational Tools: Teach divisibility and factoring concepts
- Optimization Problems: Find valid array dimensions or groupings
- Number Theory Research: Study divisor functions and relationships
Best Practices
- Handle large outputs: Highly composite numbers can have many divisors
- Use proper divisors: When working with perfect/abundant number calculations
- Check primality: Primes always have exactly 2 divisors
- Consider performance: Very large numbers may have many divisors
- Cache results: Divisors of commonly used numbers