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;
- }
- int nastepna_pierwsza(int liczba)
- {
- int s;
- liczba=liczba+1;
- while(liczba>0)
- {
- s=liczba;
- if(liczba_pierwsza(s)==1)
- {
- return liczba;
- }
- else
- {
- liczba++;
- }
- }
- }
- int main()
- {
- int a;
- cout << "Podaj liczbe naturalna, a ja podam nastepna liczbe pierwsza: "<< endl;
- cin >> a;
- cout << nastepna_pierwsza(a);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement