User Rating 0.0
Total Usage 0 times
Range: 1 to 53 (limited by JS integer precision)
Quick presets:
Is this tool helpful?

Your feedback helps us improve.

About

An almost perfect number is an integer n for which the sum-of-divisors function σ(n) = 2n 1. Equivalently, the sum of proper divisors falls exactly 1 short of n itself. Every known almost perfect number is a power of 2. Whether a non-power-of-2 almost perfect number exists remains an open problem in number theory. Miscounting divisors or confusing "almost perfect" with "deficient" leads to classification errors in combinatorial and cryptographic applications that rely on divisor function properties.

This tool operates in two modes. The generator mode computes the first N almost perfect numbers directly as 2k values. The range search mode performs brute-force divisor summation across an arbitrary interval [a, b] to independently verify each candidate. For ranges exceeding 100,000 integers, computation is offloaded to a Web Worker. Note: the tool approximates large σ(n) calculations using trial division up to n. Results for n beyond 253 lose precision due to JavaScript floating-point limits.

almost perfect numbers divisor sum number theory sigma function powers of 2 aliquot sum number generator

Formulas

A positive integer n is almost perfect if the sum-of-divisors function satisfies:

σ(n) = 2n 1

The sum-of-divisors function is computed as:

σ(n) = d | n d

This equals the sum over all positive divisors d of n. The deficiency of n is defined as:

D(n) = 2n σ(n)

An almost perfect number has deficiency exactly 1. For powers of 2, the divisor sum follows a geometric series:

σ(2k) = ki=0 2i = 2k+1 1

Since 2k+1 1 = 2 2k 1, every power of 2 satisfies the condition. The brute-force verification algorithm computes σ(n) by trial division up to n, yielding O(n) per candidate.

Where: σ(n) = sum of all positive divisors of n; D(n) = deficiency; k = non-negative integer exponent; d | n means d divides n.

Reference Data

kn = 2kσ(n)2n 1Proper Divisor SumDeficiency
011101
123311
247731
38151571
4163131151
5326363311
664127127631
71282552551271
82565115112551
9512102310235111
1010242047204710231
1120484095409520471
1240968191819140951
138192163831638381911
14163843276732767163831
15327686553565535327671
1665536131071131071655351
171310722621432621431310711
182621445242875242872621431
19524288104857510485755242871
2010485762097151209715110485751

Frequently Asked Questions

For n = 2^k, the divisors are {1, 2, 4, ..., 2^k}. Their sum is a geometric series equaling 2^(k+1) − 1 = 2n − 1, which is exactly the almost perfect condition. Whether any odd almost perfect number exists is an unsolved problem. Research by Kishore (1978) showed that any odd almost perfect number must exceed 10^30 and have at least 6 distinct prime factors.
A perfect number has σ(n) = 2n (deficiency 0), meaning the proper divisors sum exactly to n. A deficient number has σ(n) < 2n (deficiency ≥ 1). An almost perfect number is the specific case where deficiency equals exactly 1. All almost perfect numbers are deficient, but not all deficient numbers are almost perfect. For example, 9 is deficient (σ(9) = 13, deficiency = 5) but not almost perfect.
Theoretically yes. The range search computes σ(n) by trial division for every integer in the interval and checks if σ(n) = 2n − 1. If such a number existed within the range, it would be flagged. In practice, computational searches up to 10^18 have found none. The tool supports ranges up to 10^7 comfortably in the Web Worker; larger ranges will be slower due to O(√n) per candidate.
JavaScript uses IEEE 754 double-precision floats, which represent integers exactly up to 2^53 (9,007,199,254,740,992). The generator mode correctly produces 2^k for k up to 52. For k = 53 and beyond, the generated values lose precision. The range search mode is constrained to Number.MAX_SAFE_INTEGER. Inputs exceeding this limit trigger a validation error toast.
The divisors of 2^k are exactly {2^0, 2^1, ..., 2^k}. By the geometric series formula, their sum equals (2^(k+1) − 1) / (2 − 1) = 2^(k+1) − 1. Since 2 × 2^k = 2^(k+1), we get σ(2^k) = 2 × 2^k − 1 = 2n − 1. This algebraic identity confirms every power of 2 is almost perfect without needing to enumerate divisors.
Each candidate n requires O(√n) operations for trial division. For a range [a, b], total work is approximately Σ√n for n in [a, b]. A range of 1,000,000 integers near 10^6 involves roughly 10^9 operations total, completing in 2-5 seconds in a Web Worker. Ranges exceeding 10^7 integers may take 30+ seconds. A progress bar and cancel button are provided for long computations.