Pythagorean triples from a leg
Enter one leg of a right triangle and get every whole-number triangle that shares it: a leg of 20 has four partners, from 20-15-25 to 20-99-101. Each triple is marked primitive or scaled, sorted by the other leg. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Leg
- 20
- Quantity
- 4
A Pythagorean triple is a triple of positive integers (a, b, c) that satisfy a² + b² = c² — the side lengths of a right triangle with integer sides. Classrooms, contest problems, and generation of sample right triangles often start from a single known leg and ask which integer partners complete the equation. This capability takes one leg length and returns every matching triple: the fixed leg, every compatible other leg, the hypotenuse, and whether the triple is primitive.
What Pythagorean triples from a fixed leg mean
When you fix one leg a of a right triangle and insist that the other leg b and the hypotenuse c are also positive integers, you are asking for every solution of a² + b² = c² with that a held constant. The smallest such triple is the familiar 3-4-5 family; every integer leg of three or more appears in at least one triple, sometimes in several.
Some solutions are primitive — gcd(a, b, c) equals one — while others are integer multiples of a smaller triple, such as 6-8-10 from 3-4-5. Textbooks may ask only for the primitive partner, but construction problems, pixel-perfect right angles, and integer lattice paths often need the full list. Enumerating by hand means searching for b such that a² + b² is a perfect square, which grows tedious as a increases and is easy to miss a mid-range partner.
Automating the search keeps the list complete, ordered, and ready for the next step in a pipeline, a homework check, or a generator of sample geometry data.
How the capability finds every matching triple
Algebraically, a² + b² = c² rearranges to c² − b² = a², or (c − b)(c + b) = a². The engine therefore walks every positive divisor pair (d, e) of a² with d = c − b, e = c + b, d less than e, and d and e of the same parity so that b and c come out as integers: b equals (e − d) divided by two and c equals (e + d) divided by two.
Each valid pair becomes a triple (a, b, c) with a equal to the requested leg; the engine also records whether gcd(a, b, c) is one so you can tell primitive triples from scaled ones without a second pass. There is no randomness, no clock dependency, and no network call.
What you can do with it
Homework and contest checks
Verify a student’s full list of integer triples for a given leg against one canonical response, including which entries are primitive.
Lattice and CAD right angles
Pick integer other-leg and hypotenuse partners for a fixed run length so drawings, grids, or toolpaths keep exact Pythagorean right angles without floating error.
FAQ
Why must the leg be at least three?
No positive integer Pythagorean triple has a leg of 1 or 2.
Which of the triples for a leg of 20 are primitive?
Two of the four: 20-21-29 and 20-99-101, whose three sides share no common divisor. The other two, 20-15-25 and 20-48-52, are whole multiples of smaller triangles.
What does primitive mean here?
A triple is primitive when its three sides have no common divisor other than 1. 6-8-10 is not primitive, because it is simply 3-4-5 doubled.
How large can the leg be?
Any whole number from 3 up to one million. Values below 3, decimals and anything above the ceiling are rejected with a clear message rather than an incomplete list.
How does it find every partner leg?
It rewrites a² + b² = c² as (c − b)(c + b) = a² and tries every pair of divisors of a² with the same parity. Each pair gives one whole-number triangle, so none is missed.
Related tools
For developers — API access
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.
API endpoint
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.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/numth/pythagorean-from-leg \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"leg":20}'const res = await fetch("https://api.kit.forhosting.com/numth/pythagorean-from-leg", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"leg": 20
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/numth/pythagorean-from-leg",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"leg": 20
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/numth/pythagorean-from-leg", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"leg":20}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"leg":20}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/numth/pythagorean-from-leg", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"leg": 20
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "numth.pythagorean_from_leg",
"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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
How the capability finds every matching triple
You send a JSON body with a single required field leg, a positive integer at least three and at most one million. Results are sorted by ascending other leg, then hypotenuse, so identical requests always produce the same JSON order. Invalid input — missing leg, a non-integer, a value below three, or a number above the published ceiling — fails with invalid_input and is never charged.
Where to use it and what it costs
Typical placements include verifying student answers that list all integer completions of a² + b² = c² for a fixed a, generating primitive and non-primitive right triangles for geometry demos, seeding integer coordinate pairs for graphics or CNC paths that need exact right angles, and documenting the full family of lattice right triangles that share one given side. The browser path runs locally and needs no account. Use the free browser tool when you want a quick list for a single leg, or call the API when a script, gradebook, or data job must resolve many legs the same way every time. API usage draws from prepaid KIT balance at the published $0.002 base price per successful request; failed validation does not consume balance. Keep leg inside the documented bounds so the factor walk over a² stays predictable, and treat the returned count and is_primitive flags as first-class fields rather than re-deriving them in client code that might drift from this contract.
Integration use cases
Sample right-triangle generators
Feed successive legs through the API to build libraries of integer-sided right triangles for demos, worksheets, or randomized quizzes with exact answers.
Technical questions
How do I list Pythagorean triples that use a given leg?
POST a JSON body with the integer field leg (at least 3). The response includes count and an array of triples {a, b, c, is_primitive}.
What does is_primitive mean in the response?
A triple is primitive when gcd(a, b, c) equals 1. Scaled triples such as 6-8-10 have is_primitive false because they are multiples of 3-4-5.
Is the Pythagorean triples from leg tool free?
The browser widget is free and runs locally. API calls use prepaid KIT balance at the published $0.002 base price; invalid input is not charged.
Is the result always the same for the same leg?
Yes. The algorithm is pure factor enumeration over a² with no randomness or timestamps, so identical inputs produce identical JSON.