Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int n;
- int liczba_pierwsza(int n){
- if(n<2)
- return 0;
- for(int i=2; i*i<=n; i++)
- if(n%i==0)
- return 0;
- return 1;
- }
- int main()
- {
- cout << "Podaj liczbe: ";
- cin >> n;
- if(liczba_pierwsza(n)==1){
- cout << "Liczba jest pierwsza" << endl;
- }
- else{
- cout << "Liczba nie jest pierwsza" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement