In this problem, we have to find the nearest prime number smaller than N and greater than N. (3 <= N <= 2^32). I have used Miller Rabin but it's showing TLE. Similar problem: http://www.spoj.pl/problems/PAGAIN/ asked 22 Oct '12, 00:09

You need Sieve of Eratosthenes algorhitm. you can this view here: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes answered 22 Oct '12, 00:17

a better Sieve approach. https://github.com/cacophonix/SPOJ/blob/master/PAGAIN.cpp
link
This answer is marked "community wiki".
answered 17 Apr '17, 19:40
