Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool LICZBA_PIERWSZA(int n)
- {
- if(n>1)
- {
- for(int i=2; i<n; i++)
- {
- if(n%i==0)
- {
- return false;
- }
- }
- return true;
- }
- else
- {
- return false;
- }
- }
- int NASTEPNA_PIERWSZA(int n)
- {
- for(int i=n+1; true; i++)
- {
- if(LICZBA_PIERWSZA(i)==true)
- {
- return i;
- }
- }
- }
- int main()
- {
- cout << NASTEPNA_PIERWSZA(13) << endl;
- cout << NASTEPNA_PIERWSZA(1) << endl;
- cout << NASTEPNA_PIERWSZA(80) << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment