Pythagorean triples: Difference between revisions

From Rosetta Code
Content added Content deleted
(Created page with "{{draft task}} A 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...")
 
(some 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. 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 denominators <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>.


==Task==
==Task==

Revision as of 15:52, 28 June 2011

Pythagorean triples is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

A Pythagorean triple is defined as three positive integers where , and They are called primitive triples if are coprime, that is, if their pairwise greatest common denominators . Each triple form the length of the sides of a right triangle, whose perimeter is .

Task

How many Pythagorean triples are there with a perimeter no larger than 100? Of these, how many are primitive?

Extra: Can your program handle a max perimeter of 1,000,000? What about 10,000,000? 100,000,000?