Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int liczba_pierwsza(int a)
- {
- for(int i=2;i<a;i++)
- {
- if(a%i==0)
- {
- a=0;
- return 0;
- }
- }
- a=1;
- return 1;
- }
- void pierwsze(int a,int b)
- {
- int s;
- for(a;a<=b;a++)
- {
- s=a;
- if(liczba_pierwsza(s)==1)
- {
- cout << a << ", ";
- }
- }
- }
- int main()
- {
- int a,b;
- cout << "Podaj przedzial a ja wyswietle wszystkie liczby pierwsze. Od: " << endl;
- cin >> a;
- cout << "Do: "<<endl;
- cin >> b;
- if(a>=1&&b>=1)
- {
- pierwsze(a,b);
- }
- else
- {
- cout << "Podales/as zly przedzial."<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement