Equivalent Fractions Calculator
Three tools in one: simplify any fraction to lowest terms, build an equivalent fraction with the denominator or numerator you choose, or test two fractions for equivalence with cross-products. Every answer comes with the full working shown step by step.
Simplify to lowest terms
Enter a fraction. The calculator divides top and bottom by their GCF.
Build an equivalent fraction
Enter a fraction and the denominator or numerator you want. The target must be a multiple.
Are two fractions equivalent?
Enter both fractions. Cross-products decide — no guessing.
"use strict";
/* == PURE (tested by test_tool.js) == */ function tgcd(a, b) { a = Math.abs(a); b = Math.abs(b); while (b) { var t = a % b; a = b; b = t; } return a || 1; } function tred(n, d) { if (d === 0) return { ok: false, err: 'zero denominator' }; if (d < 0) { n = -n; d = -d; } if (n === 0) return { ok: true, n: 0, d: 1, g: 1 }; var g = tgcd(n, d); return { ok: true, n: n / g, d: d / g, g: g }; } function tsame(a, b) { return a.n * b.d === b.n * a.d; } /* parse two integer fields into a reduced fraction */ function tparseFrac(ns, ds) { var n = parseInt(String(ns).trim(), 10), d = parseInt(String(ds).trim(), 10); if (isNaN(n) || isNaN(d)) return { ok: false, err: 'Please enter whole numbers for the numerator and denominator.' }; if (d === 0) return { ok: false, err: 'The denominator cannot be zero.' }; var r = tred(n, d); r.input = { n: n, d: d }; return r; } /* simplify n/d: full step data */ function simplifyCalc(n, d) { var p = tparseFrac(n, d); if (!p.ok) return p; return { ok: true, inN: p.input.n, inD: p.input.d, n: p.n, d: p.d, g: p.g }; } /* build an equivalent fraction: target denominator D (mode 'den') or numerator N (mode 'num') */ function buildCalc(n, d, mode, target) { var p = tparseFrac(n, d); if (!p.ok) return p; var t = parseInt(String(target).trim(), 10); if (isNaN(t) || t <= 0) return { ok: false, err: 'The target must be a positive whole number.' }; var k; if (mode === 'den') { if (t % p.input.d !== 0) return { ok: false, err: t + ' is not a multiple of ' + p.input.d + ' — an equivalent fraction with denominator ' + t + ' does not exist. The denominator must be a multiple of ' + p.input.d + '.' }; k = t / p.input.d; return { ok: true, inN: p.input.n, inD: p.input.d, k: k, outN: p.input.n * k, outD: t, mode: 'den' }; } if (p.input.n === 0) return { ok: false, err: 'The numerator is 0, so no positive target numerator can be reached.' }; if (t % p.input.n !== 0) return { ok: false, err: t + ' is not a multiple of ' + p.input.n + ' — an equivalent fraction with numerator ' + t + ' does not exist. The numerator must be a multiple of ' + p.input.n + '.' }; k = t / p.input.n; return { ok: true, inN: p.input.n, inD: p.input.d, k: k, outN: t, outD: p.input.d * k, mode: 'num' }; } /* check equivalence of a/b and c/d */ function equivCalc(a, b, c, d) { var p = tparseFrac(a, b); if (!p.ok) return p; var q = tparseFrac(c, d); if (!q.ok) return q; var l = p.input.n * q.input.d, r = p.input.d * q.input.n; return { ok: true, a: p.input.n, b: p.input.d, c: q.input.n, d: q.input.d, left: l, right: r, eq: l === r }; } /* == /PURE == */ (function () { 'use strict'; function el(id) { return document.getElementById(id); } function showErr(id, msg) { var e = el(id); if (msg) { e.textContent = msg; e.classList.add('show'); } else { e.classList.remove('show'); } } function stepList(ulEl, steps) { ulEl.innerHTML = steps.map(function (s) { return '
'; }).join(''); } function fhtml(n, d) { if (d === 1) return String(n); return '' + Math.abs(n) + '' + d + ''; } function fsigned(n, d) { return (n < 0 ? '−' : '') + fhtml(Math.abs(n), d); } el('fb1').innerHTML = 'Simplify: divide the top and bottom by their GCF — n ÷ GCFd ÷ GCF'; el('fb2').innerHTML = 'Build up: multiply the top and bottom by the same k — n × kd × k'; el('fb3').innerHTML = 'Equivalent exactly when cross-products match: ab = cd iff a × d = b × c';
document.querySelectorAll('.tabbtn').forEach(function (btn) { btn.addEventListener('click', function () { document.querySelectorAll('.tabbtn').forEach(function (b) { b.classList.remove('active'); }); document.querySelectorAll('.panel').forEach(function (p) { p.classList.remove('active'); }); btn.classList.add('active'); el(btn.dataset.tab).classList.add('active'); }); });
/* tab 1: simplify */ el('calc1').addEventListener('click', function () { showErr('err1', ''); var r = simplifyCalc(el('n1').value, el('d1').value); if (!r.ok) { showErr('err1', r.err); el('res1').classList.remove('show'); return; } var steps = []; steps.push('Find the GCF of ' + r.inN + ' and ' + r.inD + ': GCF = ' + r.g + '.'); if (r.g === 1) { steps.push('The GCF is 1, so ' + fsigned(r.inN, r.inD) + ' is already in lowest terms.'); } else { steps.push('Divide top and bottom by ' + r.g + ': (' + r.inN + ' ÷ ' + r.g + ')/(' + r.inD + ' ÷ ' + r.g + ') = ' + fsigned(r.n, r.d) + '.'); } steps.push('Decimal check: ' + (r.inN / r.inD).toFixed(4) + ' — the value never changes.'); el('ans1').innerHTML = 'Simplest form = ' + fsigned(r.n, r.d) + ''; stepList(el('steps1'), steps); el('res1').classList.add('show'); });
/* tab 2: build equivalent */ el('calc2').addEventListener('click', function () { showErr('err2', ''); var mode = el('mode2').value; var r = buildCalc(el('n2').value, el('d2').value, mode, el('t2').value); if (!r.ok) { showErr('err2', r.err); el('res2').classList.remove('show'); return; } var steps = []; if (r.mode === 'den') { steps.push('Find the multiplier: ' + r.inD + ' × ? = ' + r.outD + ' gives ? = ' + r.k + '.'); steps.push('Multiply top and bottom by ' + r.k + ': (' + r.inN + ' × ' + r.k + ')/(' + r.inD + ' × ' + r.k + ') = ' + r.outN + '/' + r.outD + '.'); } else { steps.push('Find the multiplier: ' + r.inN + ' × ? = ' + r.outN + ' gives ? = ' + r.k + '.'); steps.push('Multiply top and bottom by ' + r.k + ': ' + r.outN + '/' + r.outD + '.'); } steps.push('Check: ' + (r.inN / r.inD).toFixed(4) + ' = ' + (r.outN / r.outD).toFixed(4) + ' — same value, confirmed.'); el('ans2').innerHTML = 'Equivalent fraction = ' + fsigned(r.outN, r.outD) + ''; stepList(el('steps2'), steps); el('res2').classList.add('show'); });
/* tab 3: equivalence check */ el('calc3').addEventListener('click', function () { showErr('err3', ''); var r = equivCalc(el('a3').value, el('b3').value, el('c3').value, el('d3').value); if (!r.ok) { showErr('err3', r.err); el('res3').classList.remove('show'); return; } var steps = []; steps.push('Cross-multiply: ' + r.a + ' × ' + r.d + ' = ' + r.left + '; ' + r.b + ' × ' + r.c + ' = ' + r.right + '.'); if (r.eq) { steps.push('The cross-products are equal, so the fractions name the same value.'); el('ans3').innerHTML = 'Equivalent — ' + fsigned(r.a, r.b) + ' = ' + fsigned(r.c, r.d); } else { steps.push('The cross-products differ, so the fractions name different values.'); var big = r.left > r.right ? fsigned(r.a, r.b) : fsigned(r.c, r.d); steps.push(big + ' is the larger one.'); el('ans3').innerHTML = 'Not equivalent — ' + fsigned(r.a, r.b) + ' ≠ ' + fsigned(r.c, r.d); } stepList(el('steps3'), steps); el('res3').classList.add('show'); }); })();