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 C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc149_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var X = CIn.ReadInt();
      var ans = MathTools.PrimeNumbers(100003).First(e => e >= X);

      Console.WriteLine(ans);
    }
  }

  class MathTools
  {
    public static long Gcd(long a, long b)
    {
      while (b != 0)
      {
        var mod = a % b;
        a = b;
        b = mod;
      }
      return a;
    }

    public static long Lcm(long a, long b)
    {
      return a * b / Gcd(a, b);
    }

    public static List<long> PrimeNumbers(long n)
    {
      var list = new List<long>();
      var sieve = new bool[n + 1];

      for (var i = 2; i <= n; i++)
      {
        if (!sieve[i])
        {
          list.Add(i);
          for (var j = i * 2; j <= n; j += i)
          {
            sieve[j] = true;
          }
        }
      }
      return list;
    }

    public static List<long> PrimeFactors(long n)
    {
      var list = new List<long>();
      var primeNumbers = PrimeNumbers((long)Math.Sqrt(n));

      foreach (var p in primeNumbers)
      {
        if (n == 1)
        {
          break;
        }
        while (n % p == 0)
        {
          n /= p;
          list.Add(p);
        }
      }
      if (n > 1)
      {
        list.Add(n);
      }
      return list;
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }
  }
}