"use strict"; function round2(x) { return Math.round(x * 100) / 100; } module.exports = { slug: "ratio-and-proportion-solve", title: "Solve a proportion a:b = c:x", deck_category: "other", description: "Solves the missing fourth term of a proportion a:b = c:x.", inputs: [ { name: "a", type: "number", required: true, description: "First term.", min: 0.0000001 }, { name: "b", type: "number", required: true, description: "Second term." }, { name: "c", type: "number", required: true, description: "Third term." } ], outputs: [ { name: "x", description: "The fourth term that makes a:b = c:x true." } ], steps: [ "A proportion a:b = c:x means a/b = c/x.", "Cross-multiplying gives a*x = b*c, so x = (b*c) / a.", "Round to 2 decimals." ], constants: [], sources: [ { kind: "edition_page", value: "Standard arithmetic reference (ratio and proportion, cross-multiplication).", title: "Ratio and proportion, cross-multiplication method", publisher: "Standard arithmetic reference", retrieved_utc: "2026-09-30T19:57:00Z", note: "x = b*c/a from a:b = c:x." } ], disclaimer: null, questionText(inputs) { return `If ${inputs.a}:${inputs.b} = ${inputs.c}:x, what is x?`; }, run(inputs) { const { a, b, c } = inputs || {}; for (const [name, v] of Object.entries({ a, b, c })) { if (typeof v !== "number" || Number.isNaN(v)) throw new Error(`${name} must be a number`); } if (a === 0) throw new Error("a must be non-zero"); const x = round2((b * c) / a); return { answer: `${x.toFixed(2)}`, values: { x } }; }, examples: [ { name: "worked example", inputs: { a: 2, b: 3, c: 10 }, expected: { answer: "15.00" }, check: "Cross-multiply to check: 2*15=30 and 3*10=30, equal, so x=15.00 is correct." }, { name: "test vector: larger numbers", inputs: { a: 4, b: 9, c: 16 }, expected: { answer: "36.00" }, check: "Cross-multiply to check: 4*36=144 and 9*16=144, equal, so x=36.00 is correct." } ] };