Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //C++
- #include <iostream>
- using namespace std;
- int main(){
- int n;
- bool prim;
- cin >> n;
- prim = false;
- while(! prim){
- n++;
- prim = true;
- if(n<2)
- prim = false;
- if(n % 2 == 0 && n > 2)
- prim = false;
- for(int d = 3 ; d * d <= n ; d += 2)
- if(n % d == 0)
- prim = false;
- }
- cout << n;
- return 0;
- }
- //Python
- def primality(n):
- if n < 2:
- return False
- if n < 4:
- return True
- if n % 2 == 0:
- return False
- i = 3
- while i * i <= n:
- if n % i == 0:
- return False
- i += 2
- return True
- x = int(raw_input())
- done = False
- i = x + 1
- while done == False:
- if primality(i) == True:
- print(i)
- done = True
- i += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement