PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000010. Số nguyên tố đứng ngay sau N (Prime After N)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Số nguyên tố đứng ngay sau N (Prime After N)
Prime After N
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given a positive integer , find the smallest prime number strictly greater than . Even if itself is prime, the required answer must be greater than .
Input
One line containing the positive integer .
Output
Print the smallest prime integer satisfying .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
5
Output
7
Explanation
The prime is not eligible because the answer must be strictly greater. is composite and is prime, so the answer is .
Input
21
Output
23
Explanation
is an even composite, while is prime. Therefore the first prime greater than is .