Advertisement
jelyslime

kolko stupki za algoritam na efklit

Jan 26th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int counter = 0;
  6.  
  7. int gcd(int a, int b)
  8. {
  9.     if (a == 0)
  10.         return b;
  11.  
  12.     counter++;
  13.     return gcd(b % a, a);
  14. }
  15.  
  16. int main() {
  17.  
  18.     int numberOne, numberTwo;
  19.     cout << "Vuvedi dvete chisla" << endl;
  20.     cin >> numberOne >> numberTwo;
  21.     int rezgcd = gcd(numberOne, numberTwo);
  22.     cout << "gcd = " << rezgcd << " stupki: " << counter << endl;
  23.     counter = 0;
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement