How To Find All Factors Of A Number

4 min read

Finding all factors of a number is a fundamental skill in mathematics that helps with simplifying fractions, solving equations, and understanding number patterns. Day to day, whether you are preparing for a test, working on a coding challenge, or just curious about the properties of integers, knowing how to find all factors of a number efficiently can save time and deepen your insight into arithmetic. This guide walks you through several reliable methods, explains the reasoning behind each technique, and provides step‑by‑step examples so you can apply the approach that best fits your needs That's the part that actually makes a difference. Less friction, more output..


What Are Factors (Divisors)?

A factor (also called a divisor) of an integer n is any whole number that divides n without leaving a remainder. Think about it: in other words, if a × b = n, then both a and b are factors of n. Factors always come in pairs, except when the number is a perfect square, in which case the square root pairs with itself That alone is useful..

Not the most exciting part, but easily the most useful.

Example: For 12, the factor pairs are (1, 12), (2, 6), and (3, 4). Thus the complete list of factors is 1, 2, 3, 4, 6, 12.

Understanding this pairing property is the key to many fast factor‑finding strategies.


Method 1: Trial Division Up to the Square Root

The most straightforward way to list all factors is to test each integer from 1 up to √n and record both the divisor and its complementary partner.

Why √n?

If d > √n divides n, then the complementary factor n/d must be < √n. Because of this, checking only up to the square root guarantees you encounter every factor pair exactly once Easy to understand, harder to ignore..

Step‑by‑Step Procedure

  1. Calculate limit = ⌊√n⌋ (the greatest integer ≤ √n).
  2. Initialize an empty list factors.
  3. Loop i from 1 to limit (inclusive).
    • If n mod i == 0 (i.e., i divides n evenly):
      • Add i to factors.
      • Compute the partner j = n / i.
      • If j ≠ i (to avoid duplication for perfect squares), add j to factors.
  4. Sort the factors list in ascending order (optional but helpful for readability).

Example: Find All Factors of 84

  1. √84 ≈ 9.165 → limit = 9.
  2. Test each i:
i 84 mod i Factor? Partner (84/i)
1 0 yes 84
2 0 yes 42
3 0 yes 28
4 0 yes 21
5 4 no –
6 0 yes 14
7 0 yes 12
8 4 no –
9 3 no –

This changes depending on context. Keep that in mind.

  1. Collected factors: 1, 84, 2, 42, 3, 28, 4, 21, 6, 14, 7, 12.
  2. Sorted: 1, 2, 3, 4, 6, 7, 12, 14, 21, 28, 42, 84.

This method runs in O(√n) time, which is fast enough for numbers up to at least 10¹² on a modern computer.


Method 2: Prime Factorization + Combination of Powers

When you need to find factors repeatedly (e.Worth adding: g. , for many queries) or you are interested in the structure of the divisor set, prime factorization offers a powerful alternative.

Core Idea

If n = p₁^{a₁} × p₂^{a₂} × … × p_k^{a_k} (where each p_i is prime), then every divisor of n can be expressed as

[ d = p₁^{b₁} \times p₂^{b₂} \times \dots \times p_k^{b_k} ]

where each exponent b_i ranges from 0 to a_i (inclusive). The total number of divisors is

[ \tau(n) = (a₁+1)(a₂+1)\dots(a_k+1). ]

Steps

  1. Factorize n into its prime powers (using trial division, a pre‑computed sieve, or any efficient algorithm).
  2. Generate all combinations of exponents (b₁,…,b_k) via nested loops or recursion.
  3. Compute the product for each combination to obtain a divisor.
  4. Collect and sort the results.

Example: Factors of 180

Prime factorization: 180 = 2² × 3² × 5¹.

  • Exponent ranges:
    • b₁ (for 2): 0, 1, 2
    • b₂ (for 3): 0, 1, 2
    • b₃ (for 5): 0, 1

Total divisors = (2+1)(2+1)(1+1) = 3 × 3 × 2 = 18 Small thing, real impact..

Generating them yields:

1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 18, 20, 30, 36, 45, 60, 90, 180 Easy to understand, harder to ignore. That's the whole idea..

Advantages

  • Once the prime factorization is known, producing the divisor list is independent of n’s size; the work depends only on the number of distinct prime factors and their exponents.
  • Useful for problems that ask for the number
Out This Week

Brand New Stories

Others Liked

Related Corners of the Blog

Thank you for reading about How To Find All Factors Of A Number. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home