Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int liczba;
- bool flaga = true;
- cout << "Podaj liczbe naturalna: ";
- cin >> liczba;
- for(int i = 2; i * i <= liczba; ++i)
- if(liczba % i == 0)
- {
- flaga = false;
- break; // automatyczne wyjście z pętli
- }
- if(flaga)
- cout << liczba << " jest liczba pierwsza.\n";
- else
- cout << liczba << " nie jest liczba pierwsza.\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement