ForHosting KIT · Math

Age ratio calculator

If two ages are in the ratio 2:1 today and 3:2 in 5 years, they are 10 and 5 now. Enter both ratios and the gap in years to get the present and future ages for homework or exam 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
First ratio value
2
Second ratio value
1
Future ratio1
3
Future ratio2
2
Years until the ratio
5
You get
First person's age
10
Second person's age
5
First person's age then
15
Second person's age then
10

Solves two-person age-ratio word problems: given the present age ratio and the future ratio after k years, recover both present ages. Free, deterministic, and private in your browser. No account required.

How age ratio problems are built

A typical exam question says that two people's ages are in one ratio today and in another ratio a number of years from now, and asks how old each one is. A ratio such as 2:1 does not give the ages themselves, only their proportion, so both ages are written as multiples of one unknown scale factor. Adding the same number of years to each and setting the new pair equal to the future ratio produces a single linear equation in that factor. Solve it, multiply back, and you have both ages: with 2:1 today and 3:2 after 5 years, the factor is 5 and the ages are 10 and 5.

When there is no single answer

The method only works when that equation has exactly one positive solution. If today's ratio and the future ratio are the same, the years cancel out and the ages cannot be pinned down, so the calculator rejects the problem instead of guessing. Every part of both ratios must be positive as well. Keep the two people in the same order in both ratios, because swapping them in the future ratio describes a different problem. Results are rounded to ten decimal places, so an answer that is not a whole number of years still comes out precise.

Edge cases, limits, and teaching use

Rejects non-positive ratios and parallel ratios that leave ages undetermined. Automation scripts can call the same pure function without installing a spreadsheet or computer-algebra system. The implementation remains fully deterministic, free in the browser for tier A, and private on-device under the parse engine with no network call for the calculation itself.

Homework and exams

Check classic quantitative age-ratio problems quickly with stable, reproducible answers.

Automation

Call the same pure function from scripts without installing a spreadsheet or CAS.

Is this free?

Yes. Tier A runs entirely in your browser without an account.

Does it call the network?

No. The parse engine keeps the calculation on-device.

How do I solve an age ratio problem by hand?

Write today's ages as 2t and t, so in 5 years they are 2t + 5 and t + 5. Setting that pair equal to 3:2 gives one simple equation; solving it, t comes out as 5, so the ages are 10 and 5.

Why does the calculator say my problem has no answer?

It only accepts problems with exactly one positive solution. If today's ratio and the future ratio are the same, the ages cannot be pinned down, and a ratio part that is zero or negative is rejected too.

Does it also tell me how old they will be?

Yes. Next to both present ages it shows the ages after the number of years you entered: with 2:1 today, 3:2 later and a gap of 5 years, the ages go from 10 and 5 to 15 and 10.

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/math/age-ratio

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/math/age-ratio \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ratio1":2,"ratio2":1,"future_ratio1":3,"future_ratio2":2,"years":5}'
{
  "ratio1": 2,
  "ratio2": 1,
  "future_ratio1": 3,
  "future_ratio2": 2,
  "years": 5
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.age_ratio",
  "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.

How the algebra recovers present ages

Clearing the proportion yields a linear equation in the single scale factor t, so the system either has one unique positive solution or is rejected as undetermined. Nothing is inferred statistically: the same arithmetic runs offline in the browser and on the paid edge path.

Inputs, outputs, and stable contracts

Optional presentation layers may coerce numeric strings from form fields before calling the pure solve function, but the core never silently coerces junk into NaN. Rounding uses round-half-up at ten decimal places so floating noise does not flip snapshot tests. Required fields are ratio1, ratio2, future_ratio1, future_ratio2, and years. Each must be a finite number; missing or non-numeric values raise invalid_input with a clear English message that the harness can match. The success payload always includes age1, age2, the echoed present ratio parts, years, and the projected future_age1 and future_age2 so clients bind UI metrics without guessing field names.

Edge cases, limits, and teaching use

Empty objects, contradictory ranges, and extremely large intermediate values that overflow IEEE-754 become explicit errors rather than null fields.

Teaching demos

Show worked examples with golden fixtures that match the free widget and the API.

What if my input is invalid?

You receive invalid_input with a clear English message.

Are results stable?

Yes. Deterministic math and golden examples freeze the contract.

Who authors this capacity?

samurai on the ForHosting KIT workshop.

Read the full KIT documentation →