Pythagorean triples: Difference between revisions

Content added Content deleted
(+Arbitrary precision Java)
(Coprime special case clarification)
Line 1: Line 1:
{{draft task}}
{{draft task}}
A [[wp:Pythagorean_triple|Pythagorean triple]] is defined as three positive integers <math>(a, b, c)</math> where <math>a\leq b\leq c</math>, and <math>a^2+b^2=c^2.</math> They are called primitive triples if <math>a, b, c</math> are coprime, that is, if their pairwise greatest common divisors <math>{\rm gcd}(a, b) = {\rm gcd}(a, c) = {\rm gcd}(b, c) = 1</math>. Each triple form the length of the sides of a right triangle, whose perimeter is <math>P=a+b+c</math>.
A [[wp:Pythagorean_triple|Pythagorean triple]] is defined as three positive integers <math>(a, b, c)</math> where <math>a\leq b\leq c</math>, and <math>a^2+b^2=c^2.</math> They are called primitive triples if <math>a, b, c</math> are coprime, that is, if their pairwise greatest common divisors <math>{\rm gcd}(a, b) = {\rm gcd}(a, c) = {\rm gcd}(b, c) = 1</math>. Because of their relationship through the Pythagorean theorem, a, b, and c are coprime if a and b are coprime (<math>{\rm gcd}(a, b) = 1</math>). Each triple forms the length of the sides of a right triangle, whose perimeter is <math>P=a+b+c</math>.


'''Task'''
'''Task'''
Line 43: Line 43:
<lang java>import java.math.BigInteger;
<lang java>import java.math.BigInteger;


public class PythTrip {
public class PythTrip{
public static void main(String[] args){
public static void main(String[] args){
long tripCount = 0, primCount = 0;
long tripCount = 0, primCount = 0;