Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <locale.h>
- using namespace std;
- int check(int a);
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int a = 1;
- int k = 0;
- cout << "Введите число: " << endl;
- while (a)
- {
- cin >> a;
- if (!a)
- break;
- k+=check(a);
- }
- cout << "Кол-во простых чисел: " << k << endl;
- _getch();
- }
- int check(int a)
- {
- if (a == 2)
- return 0;
- for (int i = 2; i < a; ++i)
- if (a%i == 0)
- return 0;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement