Advertisement
Guest User

Untitled

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