Problem:
Score: 300 points

Problem Statement

Find the minimum prime number greater than or equal to X.

Notes

A prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.

For example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.

Constraints

2 \le X \le 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

X

Output

Print the minimum prime number greater than or equal to X.

Sample Input 1

20

Sample Output 1

23

The minimum prime number greater than or equal to 20 is 23.

Sample Input 2

2

Sample Output 2

2

X itself can be a prime number.

Sample Input 3

99992

Sample Output 3

100003

Solution in Rust (1.42.0) (judge verdict: Accepted)

use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
#[allow(unused_imports)]
use std::collections::HashMap;
fn gcd(mut x: u64, mut y: u64) -> u64 {
    let mut z = x;
    let mut gcd_num = x;
    while z != 0 {
        gcd_num = z;
        z = y % x;
        y = x;
        x = z;
    }
    gcd_num
}
#[allow(dead_code)]
fn tansaku_fn(iti: usize, n: usize, kyori: &mut Vec<i32>, map: &Vec<Vec<bool>>, ans: &mut Vec<usize>) {
    let mut tansaku1: Vec<usize> = Vec::new();
    for j in 0..n {
        if map[iti][j] == true {
            tansaku1.push(j);
        }
    }
    let mut tansaku2: Vec<usize> = Vec::new();
    for j in tansaku1 {
        if kyori[j] > kyori[iti] + 1 {
            kyori[j] = kyori[iti] + 1;
            ans[j] = iti;
            tansaku2.push(j);
        }
    }
    for iti1 in tansaku2{
        tansaku_fn(iti1, n, kyori, map, ans);
    }
}

fn is_prime(i: i64) -> bool {
    for j in 2..i/2 {
        if i % j == 0 {
            return false
        }
    }
    return true
}
fn main() {
    let n = read::<i64>();
    for i in n..2*n {
        if is_prime(i) {
            println!("{}", i);
            return
        }
    }

}