Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- long long int a;
- long long int NASTEPNA_PIERWSZA(long long int liczba){
- bool b=true;
- if(liczba==1){
- return 2;
- }
- else if(liczba==2){
- return 3;
- }
- else{
- liczba++;
- for(long long int i=2; i<=sqrt(liczba); i++){
- if(liczba%i==0){
- b=!b;
- liczba++;
- i=1;
- if(b==false){
- b=!b;
- }
- }
- }
- if(b==true){
- return liczba;
- }
- }
- }
- int main()
- {
- cout << "Podaj liczbe, aby znalezc liczbe pierwsza wieksza od niej" << endl;
- cin>>a;
- if(a<0){
- cout<<"Liczba ma byc wieksza od zera";
- }
- else {
- cout<<NASTEPNA_PIERWSZA(a);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement