Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- bool prime(int n) {
- for (int i = 2; i * i <= n; i++) if (!(n % i)) return false;
- return true;
- }
- signed main() {
- ios::sync_with_stdio(0);
- cin.tie(0); cout.tie(0);
- string n = "7654321";
- do {
- if (prime(stoi(n))) {
- cout << n;
- break;
- }
- } while (prev_permutation(n.begin(), n.end()));
- }
Advertisement
Add Comment
Please, Sign In to add comment