ForHosting KIT · Math

Gaussian integer factorization

Factor any nonzero Gaussian integer into Gaussian primes: 5 becomes −i · (1+2i) · (2+i), with the unit, exponents and norms listed. It handles 1 + i, primes that stay prime and primes that split, for algebra homework and number theory checks. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
A
5
B
0
You get
Gaussian
5 -i
Norm
25
Unit re
0
Unit im
-1

Gaussian integers are complex numbers a + bi whose real and imaginary parts are ordinary integers. Just as every whole number factors uniquely into rational primes, every nonzero Gaussian integer factors uniquely into Gaussian primes up to units and order. This calculator takes the pair (a, b), runs a deterministic factorization in the ring Z[i], and returns a unit in {1, −1, i, −i}, each Gaussian prime base in a preferred first-quadrant associate, its exponent, the multiplicative norm a² + b², and a compact factorization string. Use it to check algebraic-number homework, audit cryptography demos that lean on the Gaussian integers, or feed structured primes into another pipeline without hand-rolling trial loops in Z[i]. Zero is rejected because it has no prime factorization.

What Gaussian prime factorization returns

A Gaussian integer is an element of the ring Z[i], written a + bi with a and b integers. Its multiplicative norm is N(a + bi) = a² + b², a non-negative ordinary integer that multiplies under products. The units of Z[i] are exactly 1, −1, i, and −i — the elements of norm one.

A non-unit Gaussian integer π is prime in Z[i] when it cannot be written as a product of two non-units. The structure theorem is classical: the rational prime 2 ramifies as a unit times (1 + i) squared; every rational prime p ≡ 3 (mod 4) stays prime (inert) in Z[i]; and every rational prime p ≡ 1 (mod 4) splits as a product of two conjugate Gaussian primes of norm p, which you recover by writing p as a sum of two squares.

Factoring a + bi therefore reduces to factoring its norm in the ordinary integers, lifting each rational prime into Z[i], and dividing out the matching Gaussian primes by exact division.

Where structured Gaussian primes are useful

Algebra and number-theory courses introduce Z[i] right after unique factorization in the ordinary integers, and students need a trustworthy oracle that separates units from primes and that treats 1 + i, inert primes congruent to three mod four, and split primes congruent to one mod four consistently. Cryptography demos that illustrate ideals, norms, or simple lattice examples over Z[i] can show the prime factors of a challenge element without standing up a full computer-algebra system.

Research notebooks and automated pipelines can chain this output into gcd computations, ideal generators, or norm equations.

Algebra homework and exams

Check student factorizations of a+bi into Gaussian primes, including units and the special case of 1+i powers.

Contest and LMS auto-grading

Mark Gaussian integer factorization items with a deterministic oracle that rejects zero and returns ordered prime powers.

Notebooks and crypto demos

Feed structured Z[i] primes into norm equations, ideal examples, or classroom cryptography sketches without a CAS install.

How do I factor a Gaussian integer a + bi?

The response lists a unit in {1,−1,i,−i}, Gaussian prime powers with exponents, the norm a²+b², and a factorization string.

Why is zero rejected?

The zero element of Z[i] has no prime factorization.

Is the Gaussian integer factorization calculator free?

The browser tool runs free on your device.

How are Gaussian primes written in the result?

Each prime is reduced to a preferred associate in the first quadrant (positive real part and non-negative imaginary part when possible). A separate unit field absorbs the leftover unit so the product reconstructs a+bi exactly.

What is the difference from ordinary prime factorization?

Ordinary prime factorization works in Z. This tool works in Z[i]: two may become a power of 1+i, primes ≡ 1 (mod 4) split into conjugate pairs, and primes ≡ 3 (mod 4) stay prime.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/numth/gaussian-integer-factor

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/numth/gaussian-integer-factor \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"a":5,"b":0}'
{
  "a": 5,
  "b": 0
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "numth.gaussian_integer_factor",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

The free browser path and the API share the same pure module, so classroom checks and production clients never disagree on a given input.

What Gaussian prime factorization returns

This endpoint returns that factorization in a stable shape: a preferred unit, primes sorted by ascending norm then real and imaginary parts, each prime written in the first quadrant (non-negative imaginary part and positive real part when possible), together with omega (distinct prime bases), big_omega (total multiplicity), flags for units and Gaussian primes, and a human-readable factorization string. The same deterministic path powers both the free browser tool and the paid API at $0.002 per successful request.

How to call the calculator and read the result

Composite examples include five equal to a unit times (1 + 2i) times (2 + i), two equal to a unit times (1 + i) squared, and three remaining prime as the inert rational prime three. POST a JSON object with two required integer fields: a (real part) and b (imaginary part). Alias names real or re for a, and imag or im for b, are accepted. Each part may be a JSON integer or a plain decimal string without commas, spaces, or scientific notation, and each absolute value must stay within one million so trial division on the norm remains practical. The pair (0, 0) is rejected with invalid_input and is never charged, because zero has no prime factorization in Z[i]. Units such as 1, −1, i, and −i succeed with an empty factors array, is_unit true, and the unit itself reported in the unit field. On success the body echoes a and b, a compact gaussian string such as 3+4i, the decimal norm, unit and unit_re/unit_im, an ordered factors array of objects with re, im, prime, exponent, and norm, plus omega, big_omega, factorization, is_unit, and is_prime. is_prime is true exactly when there is a single prime base with exponent one (the input is associate to a Gaussian prime). Failed validation never consumes balance; only successful factorizations bill the published $0.002.

Where structured Gaussian primes are useful

Use the browser path for interactive exploration and the API when a backend, notebook, or batch job must factor many Gaussian integers under a single prepaid KIT balance without a subscription.

Read the full KIT documentation →