Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // TI-E
- //
- // Created by Alexey on 19.10.14.
- // Copyright (c) 2014 Alexey. All rights reserved.
- //
- #include <iostream>
- #include <vector>
- using namespace std;
- int nod(int a, int b) {
- while (a != 0 && b != 0) {
- if (a > b) {
- a %= b;
- } else {
- b %= a;
- }
- }
- return a + b;
- }
- int main(int argc, const char * argv[]) {
- int n;
- vector<double> mas;
- cin >> n;
- for (int i = 0; i < n; i++) {
- if (nod(n, i) == 1) {
- mas.push_back(i);
- }
- }
- for (int i = 0; i < mas.size(); i++) {
- cout << mas[i];
- if (i != mas.size() - 1) {
- cout << ",";
- }
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement