Advertisement
Guest User

Untitled

a guest
Jan 26th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int euklides(int a, int b);
  5.  
  6. int main()
  7. {
  8. int a, b;
  9.  
  10. printf("prosze wprowadzic liczbe pierwsza\n");
  11. scanf("%d");
  12. printf("prosze wprowadzic liczbe druga\n");
  13. scanf("%d");
  14. printf("najwiekszy wspolny dzielnik liczb ktore podales to: %d\n ", euklides(a,b) );
  15.  
  16. }
  17.  
  18. int euklides(int a, int b)
  19. {
  20. if(a==0 || b==1 || a==b)
  21. return b;
  22. if(b==0 || a==1)
  23. return a;
  24.  
  25.  
  26. if(a>b)
  27. return euklides(a%b, b);
  28. if(a<b)
  29. return euklides(a, b%a);
  30.  
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement