Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include<stdio.h>
  2. int ara[1000000];
  3. int main()
  4. {
  5. int a,b,c;
  6. int count=1;
  7. for(a=3;a<=10000;a++)
  8. {
  9. for(b=4;b<=10000;b++)
  10. {
  11. for(c=5;c<=10000;c++)
  12. {
  13. if(a*a+b*b==c*c&&ara[a*a]==0&&ara[b*b]==0)
  14. {
  15. printf("\n%d. Pythagorean triplets %d %d %d",count,a,b,c);
  16. count++;
  17. ara[a*a]=1;
  18. ara[b*b]=1;
  19. }
  20. if(count==8257)
  21. {
  22. printf("Sum of %dth Pythagorean Triplet = %d",count,a+b+c);
  23. return 0;
  24. }
  25. }
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement