Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. //
  2. // main.cpp
  3. // TI-E
  4. //
  5. // Created by Alexey on 19.10.14.
  6. // Copyright (c) 2014 Alexey. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <vector>
  11.  
  12. using namespace std;
  13.  
  14. int nod(int a, int b) {
  15. while (a != 0 && b != 0) {
  16. if (a > b) {
  17. a %= b;
  18. } else {
  19. b %= a;
  20. }
  21. }
  22. return a + b;
  23. }
  24.  
  25. int main(int argc, const char * argv[]) {
  26. int n;
  27. vector<double> mas;
  28.  
  29. cin >> n;
  30.  
  31. for (int i = 0; i < n; i++) {
  32. if (nod(n, i) == 1) {
  33. mas.push_back(i);
  34. }
  35. }
  36.  
  37. for (int i = 0; i < mas.size(); i++) {
  38. cout << mas[i];
  39.  
  40. if (i != mas.size() - 1) {
  41. cout << ",";
  42. }
  43. }
  44.  
  45. cout << endl;
  46.  
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement