Next Prime

View as PDF

Submit solution


Points:5
Time limit:2.0s
Memory limit:64M

Problem type

Brute Force Practice 3

You love prime numbers. You own a number, but you suspect it might not be prime. You want a prime number, but it must be at least as large as the number you currently own. Find the smallest number that satisfies those conditions.

Input

The first line will have the integer N (1 \le N \le 2 \times 10^9)

Output

Print the number you want.

Sample Input

4

Sample Output

5

Comments


  • -7
    Anix55
     commented on Oct. 15, 2015
    TLE

    what does TLE mean?


    • -1
      Xyene
       commented on Oct. 15, 2015

      It means your program has exceeded the per-testcase time limit (in this case, 2 seconds). You can hover over status codes, as their alt text provides more details on what they are.


  • 0
    bobhob314
     commented on Jan. 6, 2015
    Sieve?

    Are there any pointers you could give me to solve this question? Should I use the Sieve or something? I'm stuck :(


    • -1
      FatalEagle
       commented on Jan. 6, 2015

      The name of the problem might give a hint. Specifically, "Brute Force Practice 3".


  • 0
    FatalEagle
     commented on Nov. 14, 2014
    Hint

    Even though this is Brute Force Practice 3, you still need a little optimization -- for example, can you determine if a number is prime just by checking divisors up to and including the square root of a number?


  • -4
    BMP
     commented on Nov. 14, 2014
    dafuq

    Keep getting 90%, first test fails. What...


    • 0
      FatalEagle
       commented on Nov. 14, 2014

      Partial output has been enabled. You can see what output your program produced (up to about 32 bytes for now) and try to debug your code.


      • -3
        PaulOlteanu
         commented on Nov. 24, 2014

        Has the output been disabled?


        • -3
          PaulOlteanu
           commented on Nov. 24, 2014

          Nevermind. It seems the output only displays if you have less than a certain number of mistakes.


          • 1
            FatalEagle
             commented on Nov. 24, 2014

            Actually, there will not be an arrow if your program does not produce any output. That was what was really happening.


  • -4
    Yuting9
     commented on Oct. 27, 2014
    Last One Lucky

    I can't seem to get the last test to work for my code...


    • 0
      FatalEagle
       commented on Oct. 27, 2014

      Your code is incorrect. There is a corner case you missed.


      • -4
        Yuting9
         commented on Oct. 27, 2014

        what do you mean, "corner case?"


        • 0
          FatalEagle
           commented on Oct. 27, 2014

          If I wrote it here, it wouldn't be a corner case anymore. Make sure your solution is valid for all possible inputs within the range specified.


  • 0
    JannyWang
     commented on Oct. 16, 2014
    Janny

    Does it have to work for decimals?


    • 2
      quantum
       commented on Oct. 16, 2014

      Inputs are integer only.


  • 2
    quantum
     commented on Sept. 27, 2014
    Not fair

    Not fair how /^1?$|^(11+?)\1+$/ fails.


    • 6
      FatalEagle
       commented on Sept. 27, 2014

      If only the memory limit was a few GB more and you had a few more days to run your program!