Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int DingDong(int a , int b)
  7. {
  8. while(b)
  9. {
  10. int r = a % b;
  11. a = b;
  12. b = r;
  13. }
  14.  
  15. return a;
  16. }
  17. int main()
  18. {
  19. int n , x , y , z , max = 0 , div;
  20.  
  21. cin >> n;
  22.  
  23. for(int i = 1 ; i <= n ; i++)
  24. {
  25. cin >> x;
  26.  
  27. if(i == 1)
  28. div = x;
  29.  
  30. div = DingDong(div , x);
  31.  
  32. }
  33. cout << div;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement