Advertisement
haufont

Untitled

Jul 23rd, 2016
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. long long nod1(long long a, long long b)
  2. {
  3. if (b == 0)
  4. {
  5. return a;
  6. }
  7. else
  8. {
  9. if (a == 0)
  10. {
  11. return b;
  12. }
  13. else
  14. {
  15. int d = nod1(b, a%b);
  16. return d;
  17. }
  18. }
  19. }
  20. long long nod1(long long a, long long b,long long&x,long long&y)
  21. {
  22. if (b == 0)
  23. {
  24. x = 1;
  25. y = 1;
  26. return a;
  27. }
  28. else
  29. {
  30. if (a == 0)
  31. {
  32. x = 1;
  33. y = 1;
  34. return b;
  35. }
  36. else
  37. {
  38. long long x1, y1;
  39. long long d = nod1(b, a%b,x1,y1);
  40. x = y1;
  41. y = x1 - a / b*y1;
  42. return d;
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement