Please read the new rule regarding the restriction on the use of AI tools. ×

Can anyone tell me the proof of Primitive Pythagorean Triples(a,b,c) having gcd(a,b,c)=1

Revision en2, by Coder_Shubham_24, 2021-02-05 13:45:13

I was solving this question Pythagorean Theorem II

and saw some optimized solution based on this relation seems

Saw some solved optimized codes using this relations seems gcd(a,b,c)=1

int n,m=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;(i*i+j*j<=n&&i>j);j++)
		{
			if((i-j)%2==1)
				if(gcd(i,j)==1)
					m+=n/(i*i+j*j);
		}
	}
	cout<<m;

I know a,b,c are relatively prime but is it enough to know that ?

Can somebody tell me proof of this approach ?

Tags gcd, pythagorean triplets

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Coder_Shubham_24 2021-02-05 13:45:13 200
en1 English Coder_Shubham_24 2021-02-05 13:43:53 743 Initial revision (published)