Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <math.h>
- using namespace std;
- bool isProst(int n) {
- if(n <= 1)
- return false;
- if(n == 2)
- return true;
- for(int i = 2; i <= sqrt(n); i++)
- if(n%i == 0)
- return false;
- return true;
- }
- int main()
- {
- int a, b;
- cin >> a >> b;
- for(int i = a; i <= b; i++)
- if(isProst(i))
- cout << i << ' ';
- return 0;
- }
- /******************************************************************************
- Online C++ Compiler.
- Code, Compile, Run and Debug C++ program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <iostream>
- #include <cmath>
- #include <math.h>
- #include <vector>
- #include <set>
- using namespace std;
- int gcd (int a, int b) {
- if (b == 0)
- return a;
- else
- return gcd (b, a % b);
- }
- int phi (int n) {
- int result = n;
- for (int i=2; i*i<=n; ++i)
- if (n % i == 0) {
- while (n % i == 0)
- n /= i;
- result -= result / i;
- }
- if (n > 1)
- result -= result / n;
- return result;
- }
- int main()
- {
- int n;
- cin >> n;
- cout << "Порядок Z" << n << ": " << phi(n) << '\n' << "Элементы: ";
- vector<int> vc;
- for(int i = 1; i < n; i++)
- if(gcd(i, n) == 1) {
- vc.push_back(i);
- cout << i << ' ';
- }
- cout << '\n';
- for(int i = 0; i < vc.size(); i++) {
- cout << "Элемент " << vc[i] << ": ";
- set<int> st;
- int start = vc[i];
- st.insert(start);
- for(int j = 0; j < 10000; j++) {
- start = (start * vc[i]) % n;
- st.insert(start);
- }
- cout << "("<< st.size() << "): ";
- for (auto it = st.begin(); it != st.end(); ++it)
- cout << *it << ' ';
- cout << '\n';
- }
- return 0;
- }
- #include <iostream>
- #include <cmath>
- #include <math.h>
- #include <vector>
- #include <set>
- using namespace std;
- int main()
- {
- //степени a + циклическая группа которую порождает
- int a, n;
- cin >> a >> n;
- int cur = a;
- set<int> st;
- for(int i = 1; i < 300; i++) {
- //cout << a << "^" << i << " = " << cur << "(-" << n - cur << ")(mod " << n << ")" << '\n';
- st.insert(cur);
- cur = (cur * a)%n;
- }
- cout << "Порождает циклическую подгруппу Z" << n << " порядка " << st.size() << ":" << '\n';
- for (auto it = st.begin(); it != st.end(); ++it)
- cout << *it << ' ';
- cout << '\n';
- cur = a;
- for(int i = 1; i < 300; i++) {
- cout << a << "^" << i << " = " << cur << "(-" << n - cur << ")(mod " << n << ")" << '\n';
- cur = (cur * a)%n;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement