Is There a Formula for Composite Numbers?
At a glance
- 1. Use the definition
A composite integer is a positive integer greater than 1 that can be written as a product of two smaller positive integers.
- 2. Check small divisors
To test n, look for a divisor d with 2 ≤ d ≤ the square root of n.
- 3. Classify the result
If such a divisor exists, n is composite; otherwise, n is prime, provided n is greater than 1.
- 4. Generate examples
Products such as n(n + 1) are always composite for integers n ≥ 2, but do not list every composite.
A composite number is a positive integer greater than 1 that has a factor other than 1 and itself. The basic formula is a factorization: , where and are integers greater than 1. If you want to decide whether a particular number is composite, you can use this definition and make the search efficient by checking divisors only up to its square root.
There is not one standard simple formula that lists every composite number in order. Depending on what you mean by “formula,” you might want a definition, a test for a given number, or a way to generate some composite numbers. These are related but different tasks.
The defining formula
For an integer , the following are equivalent:
- is composite.
- There are integers such that .
- There is an integer divisor of with .
When and both factors exceed 1, you can choose the order so that . Then , which means . Thus every composite number has a divisor no larger than its square root.
This gives the useful characterization
The restriction matters. The number 1 is neither prime nor composite. A prime number is greater than 1 and has no positive divisors except 1 and itself.
How to test a number
To check whether an integer is composite:
- Find the integer part of .
- Test whether any integer from 2 up to that value divides evenly.
- If one does, is composite. If none does, is prime.
You do not need to test divisors larger than . If had a factor larger than , its paired factor in the product would have to be smaller than and would already have been found.
Worked example: Is 91 composite?
Since , test the possible divisors from 2 through 9. The number 91 is not divisible by 2, 3, 4, or 5. But
Because 7 is a divisor greater than 1, 91 is composite. There is no need to test 10, 11, or any larger possible divisor.
For comparison, to test 29 you only need to check 2, 3, 4, and 5, because . None divides 29, so 29 is prime.
Formulas that generate composites
Many formulas produce composite numbers without producing all of them. For example,
produces a composite number for every integer , since it is a product of two integers greater than 1. Setting gives 6, 12, and 20. This sequence does not include every composite number: for instance, it does not produce 9.
Another useful construction is . For any integer and any integer with , the number is composite. Indeed, divides and also divides , so it divides their sum; moreover, . For example, with and ,
This construction makes particular composite numbers, but it is not a formula for listing every composite number.
Common mistakes
- Treating 1 as composite: It is neither prime nor composite under the standard definition.
- Checking only prime divisors without explaining why: It is enough to test prime divisors up to , since any composite divisor has a prime factor. Testing every integer in that range also works, though it may take longer.
- Assuming every product formula lists all composites: A formula such as gives a family of composites, not the complete set.
- Testing divisors beyond the square root: That work is unnecessary because factors occur in pairs, with at least one factor no greater than .
For a specific integer, the square-root divisor test is usually the most useful meaning of a “formula for composite numbers.” For a sequence or construction, first specify whether you need to generate some composites or enumerate all of them; those are different goals.
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.