← Math & statistics

Prime factorization with step-by-step trial division

Enter an integer n (|n| ≥ 2) to see every division step, τ(n), σ(n), φ(n), and a factor tree. Add optional integer m to compare exponents and derive gcd/lcm.

Other languages 日本語 | English | 简体中文 | 繁體中文 | 繁體中文(香港) | Español | Español (LatAm) | Español (México) | Português (Brasil) | Português (Portugal) | Bahasa Indonesia | Tiếng Việt | 한국어 | Français | Deutsch | Italiano | Русский | हिन्दी | العربية | বাংলা | اردو | Türkçe | ไทย | Polski | Filipino | Bahasa Melayu | فارسی | Nederlands | עברית | Čeština
Embed this calculator

Inputs

Integers are parsed exactly with BigInt, so large classroom examples stay reliable. Add a second integer to compare exponents and derive gcd/lcm from both factorizations.

Digits with an optional leading minus sign. |n| must be at least 2.

If supplied, the tool factors m, builds an exponent table, and shows gcd(n, m) and lcm(n, m).

How to use in 3 steps

  1. Enter an integer n (for example, 360).
  2. Optionally enter an integer m (for example, 840).
  3. Press [Compute] to see the prime factorization, τ(n), σ(n), φ(n), the exponent table, and the factor tree.

Result summary

Factor tree

For education only. The tool factors n into primes, then uses exponents to compute τ(n), σ(n), and φ(n). If m is given, it also computes gcd and lcm from min/max exponents. Trial division up to 6k ± 1 is practical for classroom-sized integers (≈10¹³).

How to use this calculator effectively

Use this page when you want a classroom-friendly prime factorization workflow: exact integer parsing with BigInt, every trial division step, a factor tree, and arithmetic functions derived from the prime exponents.

Start with the right input

Enter the integer n you want to factor. Add an optional integer m only when you also want to compare prime exponents and derive gcd(n, m) and lcm(n, m) from the two factorizations. Negative values are allowed; the tool separates -1 first and then factors the absolute value.

Read the outputs in order

Start from the canonical prime product, then scan the step log to see which divisors were tested and which ones divided cleanly. After that, use the exponent table to connect the factorization with τ(n), σ(n), φ(n), and, if m is present, gcd/lcm via min and max exponents.

How to use the factor tree

Each composite node splits by its smallest prime factor and the matching quotient until every leaf is prime. This makes the tree useful for board work, homework checks, and explaining why the canonical product and the step log agree.

Teacher-mode workflow

Turn on Teacher mode when you want to keep the step log visible while presenting. The shared URL preserves the teacher view, so you can send the same worked example to students or reopen it later without rebuilding the setup.

See also

FAQ

What integers can this tool factor?

Enter any integer with |n| ≥ 2. Very large values are supported, but the division steps may take longer to finish.

How is the factor tree drawn?

Each composite node splits by its smallest prime factor until every leaf is prime. The tree updates automatically after each calculation.

What do τ(n), σ(n), and φ(n) represent?

τ(n) is the number of positive divisors, σ(n) is their sum, and φ(n) counts integers from 1 to n that are coprime to n. This calculator derives all three from prime exponents.

Why can we get gcd and lcm from exponents?

If n and m are written as prime powers, gcd uses the minimum exponent for each prime and lcm uses the maximum. The exponent table visualizes this rule.

When should I turn on Teacher mode?

Use Teacher mode when you want the step log and supporting notes to stay open while presenting. It is especially useful for classroom projection, worksheet walk-throughs, or sharing a worked example URL that preserves the teaching view.

Related calculators