#cd-factoring-calculator {
–cd-bg: #f7f9fc;
–cd-card: #ffffff;
–cd-text: #18202f;
–cd-muted: #5c667a;
–cd-border: #d9e0ec;
–cd-primary: #2357c6;
–cd-primary-dark: #173d8f;
–cd-soft: #eef4ff;
–cd-success: #116b45;
–cd-error: #b42318;
–cd-warning: #8a5a00;
max-width: 1120px;
margin: 0 auto;
padding: 18px;
color: var(–cd-text);
font-family: Arial, Helvetica, sans-serif;
line-height: 1.55;
box-sizing: border-box;
}#cd-factoring-calculator * {
box-sizing: border-box;
}#cd-factoring-calculator h2,
#cd-factoring-calculator h3 {
color: var(–cd-text);
line-height: 1.25;
margin: 0 0 12px;
}#cd-factoring-calculator p {
margin: 0 0 14px;
}#cd-factoring-calculator .cd-hero {
background: linear-gradient(135deg, #ffffff 0%, #eef4ff 100%);
border: 1px solid var(–cd-border);
border-radius: 14px;
padding: 22px;
margin-bottom: 20px;
}#cd-factoring-calculator .cd-label {
display: inline-flex;
align-items: center;
gap: 6px;
width: fit-content;
padding: 5px 10px;
border-radius: 999px;
background: #e7efff;
color: #1945a3;
font-size: 13px;
font-weight: 700;
margin-bottom: 10px;
}#cd-factoring-calculator .cd-tool-grid {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(280px, 0.85fr);
gap: 18px;
align-items: start;
margin-top: 18px;
}#cd-factoring-calculator .cd-panel {
background: var(–cd-card);
border: 1px solid var(–cd-border);
border-radius: 12px;
padding: 18px;
box-shadow: 0 8px 22px rgba(24, 32, 47, 0.06);
}#cd-factoring-calculator .cd-mode-tabs {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-bottom: 16px;
}#cd-factoring-calculator .cd-mode-btn,
#cd-factoring-calculator .cd-button,
#cd-factoring-calculator .cd-secondary-button {
border: 0;
border-radius: 10px;
padding: 12px 14px;
font-weight: 700;
cursor: pointer;
font-size: 15px;
min-height: 44px;
}#cd-factoring-calculator .cd-mode-btn {
background: #edf1f8;
color: var(–cd-text);
border: 1px solid var(–cd-border);
}#cd-factoring-calculator .cd-mode-btn.cd-active {
background: var(–cd-primary);
color: #ffffff;
border-color: var(–cd-primary);
}#cd-factoring-calculator .cd-input-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px;
margin-bottom: 14px;
}#cd-factoring-calculator .cd-input-row {
margin-bottom: 14px;
}#cd-factoring-calculator label {
display: block;
font-size: 14px;
font-weight: 700;
margin-bottom: 6px;
color: var(–cd-text);
}#cd-factoring-calculator input,
#cd-factoring-calculator select {
width: 100%;
border: 1px solid var(–cd-border);
border-radius: 10px;
padding: 12px;
font-size: 16px;
color: var(–cd-text);
background: #ffffff;
}#cd-factoring-calculator input:focus,
#cd-factoring-calculator select:focus {
outline: 3px solid rgba(35, 87, 198, 0.16);
border-color: var(–cd-primary);
}#cd-factoring-calculator .cd-expression {
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
padding: 12px;
background: var(–cd-bg);
border: 1px solid var(–cd-border);
border-radius: 10px;
margin-bottom: 14px;
font-weight: 700;
}#cd-factoring-calculator .cd-actions {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-top: 10px;
}#cd-factoring-calculator .cd-button {
background: var(–cd-primary);
color: #ffffff;
}#cd-factoring-calculator .cd-button:hover {
background: var(–cd-primary-dark);
}#cd-factoring-calculator .cd-secondary-button {
background: #edf1f8;
color: var(–cd-text);
border: 1px solid var(–cd-border);
}#cd-factoring-calculator .cd-result-box {
background: #0f1f3d;
color: #ffffff;
border-radius: 12px;
padding: 18px;
min-height: 220px;
}#cd-factoring-calculator .cd-result-title {
font-size: 13px;
text-transform: uppercase;
letter-spacing: 0.06em;
color: #b9c8e8;
margin-bottom: 8px;
}#cd-factoring-calculator .cd-main-result {
font-size: 25px;
font-weight: 800;
line-height: 1.25;
word-break: break-word;
margin-bottom: 10px;
}#cd-factoring-calculator .cd-result-detail {
color: #dbe6ff;
font-size: 15px;
}#cd-factoring-calculator .cd-error {
display: none;
margin-top: 12px;
padding: 10px 12px;
border-radius: 10px;
background: #fff1f0;
color: var(–cd-error);
border: 1px solid #ffd0cc;
font-weight: 700;
}#cd-factoring-calculator .cd-note {
margin-top: 12px;
padding: 10px 12px;
border-radius: 10px;
background: #fff8e6;
color: var(–cd-warning);
border: 1px solid #ffe1a3;
font-size: 14px;
}#cd-factoring-calculator .cd-section {
border-top: 1px solid var(–cd-border);
padding-top: 22px;
margin-top: 22px;
}#cd-factoring-calculator .cd-section:first-of-type {
border-top: 0;
}#cd-factoring-calculator .cd-two-col {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 16px;
}#cd-factoring-calculator .cd-info-card {
background: var(–cd-bg);
border: 1px solid var(–cd-border);
border-radius: 12px;
padding: 16px;
}#cd-factoring-calculator ul,
#cd-factoring-calculator ol {
margin: 0 0 14px 20px;
padding: 0;
}#cd-factoring-calculator li {
margin-bottom: 8px;
}#cd-factoring-calculator code {
background: #eef1f6;
padding: 2px 5px;
border-radius: 5px;
font-size: 0.95em;
}#cd-factoring-calculator details {
border: 1px solid var(–cd-border);
border-radius: 10px;
padding: 12px 14px;
background: #ffffff;
margin-bottom: 10px;
}#cd-factoring-calculator summary {
cursor: pointer;
font-weight: 800;
color: var(–cd-text);
}#cd-factoring-calculator details p {
margin-top: 10px;
margin-bottom: 0;
color: var(–cd-muted);
}#cd-factoring-calculator .cd-hidden {
display: none;
}@media (max-width: 820px) {
#cd-factoring-calculator {
padding: 12px;
}#cd-factoring-calculator .cd-tool-grid,
#cd-factoring-calculator .cd-two-col {
grid-template-columns: 1fr;
}#cd-factoring-calculator .cd-input-grid {
grid-template-columns: 1fr;
}#cd-factoring-calculator .cd-hero,
#cd-factoring-calculator .cd-panel {
padding: 16px;
}#cd-factoring-calculator .cd-main-result {
font-size: 22px;
}#cd-factoring-calculator .cd-actions {
display: grid;
grid-template-columns: 1fr;
}
}
Factoring Calculator
AlgebraUse this factoring calculator to factor a quadratic expression or break an integer into prime factors, with the key steps shown under the result.
What the Result Means
Factoring rewrites a number or expression as a product of simpler parts. For a quadratic expression, the result shows which binomials multiply back to the original expression. For an integer, the result shows the prime numbers that multiply back to the original number.
Formula and Method
Quadratic factoring
The calculator works with:
ax^2 + bx + c
It looks for two linear factors:
(px + q)(rx + s)
where p*r = a, q*s = c, and p*s + q*r = b.
Integer factoring
Prime factorization rewrites an integer as prime numbers only.
Example:
360 = 2^3 * 3^2 * 5
The calculator divides by prime candidates until the remaining value is prime.
How to Use This Factoring Calculator
- Choose Quadratic to factor an expression in the form
ax^2 + bx + c. - Enter the values of
a, b, and c as integers. - Choose Integer to factor a whole number into prime factors.
- Click Calculate to update the result on the same page.
- Use Copy Result if you want to reuse the visible answer.
- Use Clear to reset the active calculator mode.
Worked Example
For the quadratic expression x^2 + 5x + 6, the calculator looks for two numbers that multiply to 6 and add to 5. Those numbers are 2 and 3.
So the factored form is:
x^2 + 5x + 6 = (x + 2)(x + 3)
Checking the result: (x + 2)(x + 3) expands to x^2 + 3x + 2x + 6, which simplifies to x^2 + 5x + 6.
Common Use Cases
For students
Use the calculator to check algebra homework, compare expanded and factored forms, or study how trinomials split into binomials.
For number work
Use integer factorization to simplify fractions, find prime factors, prepare for LCM or GCD problems, and check divisibility patterns.
Common Mistakes
- Entering the coefficients in the wrong order. The quadratic format is always
ax^2 + bx + c. - Using decimals when exact integer factoring is expected.
- Expecting every quadratic to factor nicely over integers. Some expressions are not factorable into integer binomials.
- Confusing factoring with solving. Factoring rewrites the expression, while solving finds values of
x. - For integer factoring, entering a value outside the safe browser range can slow down calculation.
Limitations
This calculator focuses on quadratic expressions with integer coefficients and integer prime factorization. It does not factor higher-degree polynomials such as cubic or quartic expressions. When a quadratic cannot be factored over integers, the tool may show an approximate real-factor form when real roots exist.
FAQ
What does factoring mean in algebra?
Factoring means rewriting an expression as a product of simpler expressions. For example, x^2 + 5x + 6 factors into (x + 2)(x + 3).
Can this calculator factor any polynomial?
No. This tool is designed for quadratic expressions in the form ax^2 + bx + c. It does not factor cubic, quartic, or symbolic multi-variable expressions.
What if my quadratic is not factorable?
If integer factoring is not possible, the calculator will say so. If the expression has real roots, it can also show an approximate real-factor form.
Is factoring the same as solving?
No. Factoring rewrites the expression. Solving uses the factored form or another method to find values of x that make the expression equal zero.
What is prime factorization?
Prime factorization breaks a whole number into prime numbers. For example, 84 becomes 2^2 * 3 * 7.
(function () {
function ready(fn) {
if (document.readyState === “loading”) {
document.addEventListener(“DOMContentLoaded”, fn);
} else {
fn();
}
}ready(function () {
var root = document.getElementById(“cd-factoring-calculator”);
if (!root) {
return;
}var mode = “quadratic”;
var quadBtn = document.getElementById(“cd-factor-mode-quadratic”);
var intBtn = document.getElementById(“cd-factor-mode-integer”);
var quadPanel = document.getElementById(“cd-factor-quadratic-panel”);
var intPanel = document.getElementById(“cd-factor-integer-panel”);
var calcBtn = document.getElementById(“cd-factor-calculate”);
var copyBtn = document.getElementById(“cd-factor-copy”);
var clearBtn = document.getElementById(“cd-factor-clear”);
var errorBox = document.getElementById(“cd-factor-error”);
var mainResult = document.getElementById(“cd-factor-main-result”);
var detailResult = document.getElementById(“cd-factor-detail-result”);
var preview = document.getElementById(“cd-factor-expression-preview”);
var inputA = document.getElementById(“cd-factor-a”);
var inputB = document.getElementById(“cd-factor-b”);
var inputC = document.getElementById(“cd-factor-c”);
var inputNumber = document.getElementById(“cd-factor-number”);function showError(message) {
errorBox.textContent = message;
errorBox.style.display = “block”;
}function hideError() {
errorBox.textContent = “”;
errorBox.style.display = “none”;
}function parseIntegerInput(input, name) {
var raw = String(input.value).trim();
if (raw === “”) {
return { ok: false, message: name + ” is required.” };
}var value = Number(raw);
if (!Number.isFinite(value)) {
return { ok: false, message: name + ” must be a valid number.” };
}if (!Number.isInteger(value)) {
return { ok: false, message: name + ” must be an integer.” };
}return { ok: true, value: value };
}function absInt(n) {
return Math.abs(Math.trunc(n));
}function gcdTwo(a, b) {
a = absInt(a);
b = absInt(b);while (b !== 0) {
var temp = b;
b = a % b;
a = temp;
}return a;
}function gcdThree(a, b, c) {
return gcdTwo(gcdTwo(a, b), c);
}function positiveDivisors(n) {
var value = absInt(n);
var list = [];if (value === 0) {
return [0];
}var i = 1;
while (i * i <= value) {
if (value % i === 0) {
list.push(i);
if (i !== value / i) {
list.push(value / i);
}
}
i = i + 1;
}list.sort(function (a, b) {
return a – b;
});return list;
}function signedDivisors(n) {
var base = positiveDivisors(n);
var list = [];
var i = 0;while (i < base.length) {
list.push(base[i]);
list.push(-base[i]);
i = i + 1;
}return list;
}function formatSignedNumber(n) {
if (n 0) {
parts.push(“+ ” + b + “x”);
} else {
parts.push(“- ” + Math.abs(b) + “x”);
}
}
}
}if (c !== 0) {
if (c > 0) {
parts.push(“+ ” + c);
} else {
parts.push(“- ” + Math.abs(c));
}
}return parts.join(” “);
}function formatLinear(p, q) {
var text = “”;if (p === 1) {
text = “x”;
} else {
if (p === -1) {
text = “-x”;
} else {
text = String(p) + “x”;
}
}if (q !== 0) {
text = text + formatSignedNumber(q);
}return “(” + text + “)”;
}function formatContent(content) {
if (content === 1) {
return “”;
}if (content === -1) {
return “-“;
}return String(content);
}function nearlyInteger(n) {
return Math.abs(n – Math.round(n)) < 0.0000000001;
}function roundValue(n) {
if (nearlyInteger(n)) {
return String(Math.round(n));
}
return String(Math.round(n * 1000000) / 1000000);
}function factorQuadratic(a, b, c) {
var original = formatQuadraticExpression(a, b, c);if (a === 0) {
return { ok: false, message: "The a coefficient cannot be 0 for a quadratic expression." };
}var content = gcdThree(a, b, c);
if (content === 0) {
content = 1;
}if (a < 0) {
content = -content;
}var A = a / content;
var B = b / content;
var C = c / content;if (C === 0) {
var factorText = formatContent(content) + "x" + formatLinear(A, B);
if (A === 1) {
if (B === 0) {
factorText = formatContent(content) + "x^2";
}
}return {
ok: true,
main: original + " = " + factorText,
detail: "The expression has a common factor of x. After taking out the greatest common factor, the remaining linear factor is " + formatLinear(A, B) + "."
};
}var pList = positiveDivisors(A);
var qList = signedDivisors(C);
var found = null;
var i = 0;while (i < pList.length) {
var p = pList[i];
var r = A / p;
var j = 0;while (j < qList.length) {
var q = qList[j];if (q !== 0) {
if (C % q === 0) {
var s = C / q;
if (p * s + q * r === B) {
found = { p: p, q: q, r: r, s: s };
j = qList.length;
i = pList.length;
}
}
}j = j + 1;
}i = i + 1;
}if (found) {
var exact = formatContent(content) + formatLinear(found.p, found.q) + formatLinear(found.r, found.s);
return {
ok: true,
main: original + " = " + exact,
detail: "Exact integer factorization found. Multiplying the two binomials gives the original middle term and constant."
};
}var disc = b * b – 4 * a * c;
if (disc < 0) {
return {
ok: true,
main: original + " is not factorable over the real numbers.",
detail: "The discriminant is " + disc + ", so there are no real linear factors. It also does not split into integer binomials."
};
}var sqrtDisc = Math.sqrt(disc);
var rootOne = (-b + sqrtDisc) / (2 * a);
var rootTwo = (-b – sqrtDisc) / (2 * a);
var approx = String(a) + "(x – " + roundValue(rootOne) + ")(x – " + roundValue(rootTwo) + ")";if (rootOne < 0) {
approx = String(a) + "(x + " + roundValue(Math.abs(rootOne)) + ")";
if (rootTwo < 0) {
approx = approx + "(x + " + roundValue(Math.abs(rootTwo)) + ")";
} else {
approx = approx + "(x – " + roundValue(rootTwo) + ")";
}
} else {
if (rootTwo limit) {
return { ok: false, message: “Please enter an integer from -1,000,000,000 to 1,000,000,000.” };
}var value = Math.abs(n);
var factors = [];
var divisor = 2;while (divisor * divisor 0) {
factors.push({ prime: divisor, power: count });
}if (divisor === 2) {
divisor = 3;
} else {
divisor = divisor + 2;
}
}if (value > 1) {
factors.push({ prime: value, power: 1 });
}var parts = [];
var expanded = [];
var i = 0;while (i < factors.length) {
var item = factors[i];
if (item.power === 1) {
parts.push(String(item.prime));
} else {
parts.push(String(item.prime) + "^" + item.power);
}var k = 0;
while (k < item.power) {
expanded.push(String(item.prime));
k = k + 1;
}i = i + 1;
}if (n < 0) {
parts.unshift("-1");
expanded.unshift("-1");
}return {
ok: true,
main: String(n) + " = " + parts.join(" * "),
detail: "Expanded factor list: " + expanded.join(" * ") + "."
};
}function updatePreview() {
var a = Number(inputA.value);
var b = Number(inputB.value);
var c = Number(inputC.value);if (Number.isFinite(a)) {
if (Number.isFinite(b)) {
if (Number.isFinite(c)) {
preview.textContent = formatQuadraticExpression(a, b, c);
}
}
}
}function calculate() {
hideError();try {
if (mode === "quadratic") {
var aData = parseIntegerInput(inputA, "The a coefficient");
if (!aData.ok) {
showError(aData.message);
return;
}var bData = parseIntegerInput(inputB, "The b coefficient");
if (!bData.ok) {
showError(bData.message);
return;
}var cData = parseIntegerInput(inputC, "The c constant");
if (!cData.ok) {
showError(cData.message);
return;
}var quad = factorQuadratic(aData.value, bData.value, cData.value);
if (!quad.ok) {
showError(quad.message);
return;
}mainResult.textContent = quad.main;
detailResult.textContent = quad.detail;
updatePreview();
} else {
var nData = parseIntegerInput(inputNumber, "The integer");
if (!nData.ok) {
showError(nData.message);
return;
}var factored = primeFactorize(nData.value);
if (!factored.ok) {
showError(factored.message);
return;
}mainResult.textContent = factored.main;
detailResult.textContent = factored.detail;
}
} catch (err) {
showError("Something went wrong while calculating. Please check the input values and try again.");
}
}function setMode(nextMode) {
mode = nextMode;
hideError();if (mode === "quadratic") {
quadPanel.classList.remove("cd-hidden");
intPanel.classList.add("cd-hidden");
quadBtn.classList.add("cd-active");
intBtn.classList.remove("cd-active");
} else {
intPanel.classList.remove("cd-hidden");
quadPanel.classList.add("cd-hidden");
intBtn.classList.add("cd-active");
quadBtn.classList.remove("cd-active");
}calculate();
}function clearActive() {
hideError();if (mode === "quadratic") {
inputA.value = "";
inputB.value = "";
inputC.value = "";
preview.textContent = "ax^2 + bx + c";
mainResult.textContent = "Enter coefficients to factor a quadratic.";
detailResult.textContent = "Example format: a = 1, b = 5, c = 6 gives x^2 + 5x + 6.";
} else {
inputNumber.value = "";
mainResult.textContent = "Enter an integer to factor.";
detailResult.textContent = "Example: 360 becomes 2^3 * 3^2 * 5.";
}
}function copyResult() {
hideError();
var text = mainResult.textContent + " " + detailResult.textContent;if (navigator.clipboard) {
if (navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(function () {
detailResult.textContent = detailResult.textContent + " Result copied.";
}).catch(function () {
showError("Copy failed. You can select the result text manually.");
});
return;
}
}showError("Copy is not available in this browser. You can select the result text manually.");
}quadBtn.addEventListener("click", function () {
setMode("quadratic");
});intBtn.addEventListener("click", function () {
setMode("integer");
});calcBtn.addEventListener("click", calculate);
copyBtn.addEventListener("click", copyResult);
clearBtn.addEventListener("click", clearActive);inputA.addEventListener("input", updatePreview);
inputB.addEventListener("input", updatePreview);
inputC.addEventListener("input", updatePreview);calculate();
});
}());