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