Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- int ara[100000];
- int main()
- {
- int a,b,c,ans,count=1;
- for(c=5; c<=50000; c++)
- {
- for(b=3; b<c; b++)
- {
- a=sqrt(c*c-b*b);
- if(a*a==c*c-b*b&&ara[a]==0)
- {
- printf("\n%d. Pythagorean triplets %d %d %d",count,a,b,c);
- count++;
- ara[a]=1;
- ara[b]=1;
- }
- if(count==8257)
- {
- printf("\nSum of %dth Pythagorean Triplet = %d",count,a+b+c);
- return 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement