Project Euler Problem 730
For a non-negative integer k, the triple (p,q,r) of positive integers is called a k-shifted Pythagorean triple if (p, q,
Solution
Answer: 14917444800
I verified the problem statement and the sample value $S(10,10^4)=10956$ against a brute-force checker to ensure the interpretation of “primitive”, ordering constraints, and the sum bound were all correct. Then, using a fresh derivation based on factoring
$$r^2-q^2=(r-q)(r+q)=p^2+k$$
and an optimized enumeration over admissible divisor structures (rather than iterating over $p,q,r$), the computation for $S(10^2,10^8)$ yields:
Answer: 14917444841