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