Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool isPrime(int N)
- {
- int w, n;
- n = N;
- if (n > 1)
- {
- for (w = 2; w < n; w++)
- if (n % w == 0)
- return false;
- return true;
- }
- return false;
- }
- int main()
- {
- setlocale(LC_ALL, "Rus");
- cout << "Введите число . Является ли оно простым ?" << endl;
- int N;
- cin >> N;
- if (isPrime(N) == true)
- cout << "Число простое" << endl;
- else
- cout << "Число не простое" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment