What the Factor Calculator Does
This Factor Calculator takes a single whole number and instantly returns two things: every factor (divisor) of that number, and its prime factorisation. A factor is any integer that divides your number evenly, leaving no remainder. The prime factors are the prime building blocks that multiply together to recreate the original number. It is a handy tool for homework, simplifying fractions, finding greatest common divisors, and exploring number properties.
How to Use It
There is just one input field, labelled "Find the Factors of:". Enter any integer (positive or negative) and the calculator does the rest. The tool works on the absolute value, so the factors returned are always positive. The supported range is any whole number with up to 18 digits (positive or negative); longer numbers are not processed.
- 0 is treated as a special case and returns 0.
- Negative numbers use their absolute value (e.g. -12 gives the same factors as 12).
The Formula Behind It
Rather than checking every number up to your input, the calculator loops only from 1 up to the square root of the number. For each value i that divides evenly, it records both i and its paired quotient (number ÷ i). This square-root method finds factors in pairs, which is far faster for large inputs. The results are de-duplicated and sorted in ascending order. For the prime factorisation, it uses an established primes routine (Apache Commons Math) to break the absolute value down into its prime components.
$$\text{Factors} = \left\{\, d \in \mathbb{Z}^{+} : \left|\text{Number}\right| \bmod d = 0 \,\right\}$$
Worked Example
Enter 36. The loop runs from 1 up to 7 (just past \(\sqrt{36} = 6\)):
- 1 divides 36 → record 1 and 36
- 2 divides 36 → record 2 and 18
- 3 divides 36 → record 3 and 12
- 4 divides 36 → record 4 and 9
- 6 divides 36 → record 6 (its pair is also 6, so only once)
Sorted, the factors are: 1, 2, 3, 4, 6, 9, 12, 18, 36. The prime factors are: 2, 2, 3, 3 (since \(2 \times 2 \times 3 \times 3 = 36\)).
More Worked Examples
Example 1: A prime input (29)
The calculator only tests divisors up to the square root of the number. Here \(\sqrt{29} \approx 5.39\), so the loop runs i = 1, 2, 3, 4, 5.
- \(29 \bmod 1 = 0\), so 1 is a divisor and gives the pair (1, 29).
- \(29 \bmod 2 = 1\), \(29 \bmod 3 = 2\), \(29 \bmod 4 = 1\) and \(29 \bmod 5 = 4\). None of these is zero, so none of 2–5 is a divisor.
Factors of 29: 1, 29. There are exactly two factors, so 29 is prime, and its prime factorisation is just \(29\).
Example 2: A negative input (−60)
Factors are defined as positive divisors, so the calculator works with the absolute value: \(|-60| = 60\). Since \(\sqrt{60} \approx 7.75\), the loop runs i = 1 to 7.
| i | 60 mod i | Pair found |
|---|---|---|
| 1 | 0 | (1, 60) |
| 2 | 0 | (2, 30) |
| 3 | 0 | (3, 20) |
| 4 | 0 | (4, 15) |
| 5 | 0 | (5, 12) |
| 6 | 0 | (6, 10) |
| 7 | 4 | — |
Sorted factors: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60 (12 factors). Prime factors: 2, 2, 3, 5, since
$$60 = 2 \times 2 \times 3 \times 5 = 2^2 \times 3 \times 5$$Check: \(2 \times 2 = 4\), \(4 \times 3 = 12\), \(12 \times 5 = 60\). The negatives (−1, −2, … , −60) also divide −60, but the calculator lists only the positive factors.
Example 3: A larger non-square number (210)
Since \(\sqrt{210} \approx 14.49\), the loop tests i = 1 to 14. The values that divide 210 exactly give these pairs:
| i (small factor) | 210 ÷ i (paired factor) |
|---|---|
| 1 | 210 |
| 2 | 105 |
| 3 | 70 |
| 5 | 42 |
| 6 | 35 |
| 7 | 30 |
| 10 | 21 |
| 14 | 15 |
The values 4, 8, 9, 11, 12 and 13 leave remainders, so they are not factors. Putting the small and paired factors together in order gives the full list:
1, 2, 3, 5, 6, 7, 10, 14, 15, 21, 30, 35, 42, 70, 105, 210 (16 factors).
Prime factorisation: \(210 = 2 \times 3 \times 5 \times 7\). Multiplying back: \(2 \times 3 = 6\), \(6 \times 5 = 30\), \(30 \times 7 = 210\). As a check, the divisor-count formula gives \((1+1)(1+1)(1+1)(1+1) = 16\), which matches the list.
Interpreting Your Result
Prime, composite or neither
- Exactly two factors (1 and the number itself) means the number is prime, e.g. 29 → 1, 29.
- More than two factors means the number is composite, e.g. 12 → 1, 2, 3, 4, 6, 12.
- 1 has only one factor (itself), so it is neither prime nor composite.
An odd number of factors means a perfect square
Factors normally come in pairs \((d, n/d)\). The only way to get an odd count is for one factor to pair with itself, which happens when \(d = n/d\), i.e. \(d^2 = n\). For example, 36 has the pairs (1, 36), (2, 18), (3, 12), (4, 9) and (6, 6). The 6 is counted once, so 36 has 9 factors. If the count is odd, the number is a perfect square. If it is even, it is not.
Counting divisors from the prime factorisation
If \(n = p^a \times q^b \times \dots\) with distinct primes \(p, q, \dots\), then the number of divisors is
$$d(n) = (a+1)(b+1)\cdots$$For \(36 = 2^2 \times 3^2\): \(d(36) = (2+1)(2+1) = 3 \times 3 = 9\). This lets you check that a factor list is complete.
Perfect numbers
A number is perfect when its proper factors (all factors except the number itself) add up to the number:
- 6: \(1 + 2 + 3 = 6\)
- 28: \(1 + 2 + 4 + 7 + 14 = 28\)
- 496: \(1 + 2 + 4 + 8 + 16 + 31 + 62 + 124 + 248 = 496\)
If the proper factors add up to less than the number, it is called deficient. If they add up to more, it is called abundant (12 is abundant: \(1+2+3+4+6 = 16\)).
Using two factor lists: GCD and simplifying fractions
Find the factors of both numbers. The largest factor they share is the greatest common divisor (GCD). For 36 and 48:
- 36: 1, 2, 3, 4, 6, 9, 12, 18, 36
- 48: 1, 2, 3, 4, 6, 8, 12, 16, 24, 48
The common factors are 1, 2, 3, 4, 6 and 12, so GCD(36, 48) = 12. To simplify a fraction, divide the top and bottom by the GCD:
$$\frac{36}{48} = \frac{36 \div 12}{48 \div 12} = \frac{3}{4}$$If the only common factor is 1, the numbers are coprime and the fraction is already in lowest terms.
Factors of Common Numbers (1–30)
The number of factors always equals the product of (exponent + 1) taken over the prime factorisation. Numbers with an odd number of factors are perfect squares.
| n | All factors | Number of factors | Prime factorisation | Type |
|---|---|---|---|---|
| 1 | 1 | 1 | — (empty product) | Neither prime nor composite; square |
| 2 | 1, 2 | 2 | 2 | Prime |
| 3 | 1, 3 | 2 | 3 | Prime |
| 4 | 1, 2, 4 | 3 | 2² | Composite; square |
| 5 | 1, 5 | 2 | 5 | Prime |
| 6 | 1, 2, 3, 6 | 4 | 2 × 3 | Composite (perfect number) |
| 7 | 1, 7 | 2 | 7 | Prime |
| 8 | 1, 2, 4, 8 | 4 | 2³ | Composite |
| 9 | 1, 3, 9 | 3 | 3² | Composite; square |
| 10 | 1, 2, 5, 10 | 4 | 2 × 5 | Composite |
| 11 | 1, 11 | 2 | 11 | Prime |
| 12 | 1, 2, 3, 4, 6, 12 | 6 | 2² × 3 | Composite |
| 13 | 1, 13 | 2 | 13 | Prime |
| 14 | 1, 2, 7, 14 | 4 | 2 × 7 | Composite |
| 15 | 1, 3, 5, 15 | 4 | 3 × 5 | Composite |
| 16 | 1, 2, 4, 8, 16 | 5 | 2⁴ | Composite; square |
| 17 | 1, 17 | 2 | 17 | Prime |
| 18 | 1, 2, 3, 6, 9, 18 | 6 | 2 × 3² | Composite |
| 19 | 1, 19 | 2 | 19 | Prime |
| 20 | 1, 2, 4, 5, 10, 20 | 6 | 2² × 5 | Composite |
| 21 | 1, 3, 7, 21 | 4 | 3 × 7 | Composite |
| 22 | 1, 2, 11, 22 | 4 | 2 × 11 | Composite |
| 23 | 1, 23 | 2 | 23 | Prime |
| 24 | 1, 2, 3, 4, 6, 8, 12, 24 | 8 | 2³ × 3 | Composite |
| 25 | 1, 5, 25 | 3 | 5² | Composite; square |
| 26 | 1, 2, 13, 26 | 4 | 2 × 13 | Composite |
| 27 | 1, 3, 9, 27 | 4 | 3³ | Composite |
| 28 | 1, 2, 4, 7, 14, 28 | 6 | 2² × 7 | Composite (perfect number) |
| 29 | 1, 29 | 2 | 29 | Prime |
| 30 | 1, 2, 3, 5, 6, 10, 15, 30 | 8 | 2 × 3 × 5 | Composite |
Between 1 and 30, the primes are 2, 3, 5, 7, 11, 13, 17, 19, 23 and 29, and the perfect squares are 1, 4, 9, 16 and 25. The numbers with the most factors are 24 and 30, with 8 each.
Frequently Asked Questions
What is the difference between factors and prime factors? Factors are all the numbers that divide evenly into your input. Prime factors are only the prime numbers that multiply together to form it. For 36, the factors include composite numbers like 12 and 18, while the prime factors are just 2, 2, 3, 3.
Why do negative numbers give positive factors? The calculator works with the absolute value, so -12 and 12 produce the same list of positive divisors.
Is there a size limit? Yes. Numbers can have up to 18 digits (positive or negative). Values at or beyond that limit return no result.