Primitive Triangles

Consider the triangles with integer sides $a$, $b$ and $c$ with $a \le b \le c$.
An integer sided triangle $(a,b,c)$ is called primitive if $\gcd(a, b, c)$$\gcd(a,b,c)=\gcd(a,\gcd(b,c))$$=1$.
How many primitive integer sided triangles exist with a perimeter not exceeding $10\,000\,000$?

To tackle this problem, we are dealing with what’s known as primitive Pythagorean triples in number theory.

A Pythagorean triple consists of three positive integers a, b, and c, such that a^2 + b^2 = c^2. If the gcd(a,b,c) = 1, we call this a primitive Pythagorean triple.

First, we make use of the fact that every primitive Pythagorean triple (a, b, c) can be represented as:
a = n^2 – m^2
b = 2mn and
c = n^2 + m^2 for some m, n ∈ Z, such that m > n > 0, gcd(m,n) = 1 and m and n have different parity.

We know that the perimeter p = a + b + c = 2n(n + m) <= 10^7. Let's fix m and maximize n: n <= floor(10^7/2m - m/2). As m increases, the maximum of n decreases, so to optimize the search we can start iterating m from a large value down to 1 and find the n that meets the conditions for each m. We sum up the number of suitable n for all m, and that will give us the number of primitive Pythagorean triples, hence the number of triangles with the conditions. Here is a Python script that does exactly that and calculates the result: ```python #!/usr/bin/env python3 from math import gcd, isqrt L = 10**7 s = 0 m = isqrt(L // 2) while m > 0:
n_min = m % 2 + 1
n_max = min((m – 1) // 2, L // (2 * m) – m // 2)
for n in range(n_max, n_min – 1, -1):
if gcd(m, n) == 1:
s += 1
m -= 1
Running this script will provide you with the number of primitive integer sided triangles exist with a perimeter not exceeding 10,000,000.

More Answers:
Sum of Squares
Divisibility Multipliers
Balanced Sculptures

Error 403 The request cannot be completed because you have exceeded your quota. : quotaExceeded


Recent Posts

Don't Miss Out! Sign Up Now!

Sign up now to get started for free!