#include <iostream>
using namespace std;
bool IsPrime(int n) {
int d = 2;
while (n % d != 0)
d++;
return d == n;
}
signed main() {
setlocale(LC_ALL, "Rus");
int N;
cin >> N;
if (IsPrime(N))
cout << "Число простое!";
else
cout << "Число не простое!";
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
using namespace std;
bool IsPrime(int n) {
int d = 2;
while (n % d != 0)
d++;
return d == n;
}
signed main() {
setlocale(LC_ALL, "Rus");
int N;
cin >> N;
if (IsPrime(N))
cout << "Число простое!";
else
cout << "Число не простое!";
return 0;
}