Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool czy_pierwsza(unsigned long long liczba)
- {
- if(liczba < 2)
- return false;
- for(unsigned i = 2; i * i <= liczba; ++i)
- if(liczba % i == 0)
- return false;
- return true;
- }
- int main()
- {
- unsigned long long liczba;
- cout << "Podaj liczbe naturalna: ";
- cin >> liczba;
- if(czy_pierwsza(liczba))
- 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