TTripleMistral
Product

Product features · Primitive Pythagorean triples

01

Use TripleMistral to follow the parity and coprime conditions that exclude scaled triangles before collecting the results.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Primitive Pythagorean triples

● ● ●TripleMistral●
A concrete starting point · Primitive Pythagorean triples ×
from math import gcd

def primitive_triples(limit):
    if type(limit) is not int or not 0 <= limit <= 500:
        raise ValueError("hypotenuse.limit")
    result, m = [], 2
    while m * m + 1 <= limit:
        for n in range(1, m):
            c = m * m + n * n
            if c <= limit and (m - n) % 2 and gcd(m, n) == 1:
                a, b = sorted((m * m - n * n, 2 * m * n))
                result.append((a, b, c))
        m += 1
    return sorted(result, key=lambda t: (t[2], t[0], t[1]))
✳Enumerate primitive integer right triangles whose hypotenuse is at most a supplied limit from zero through 500.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗