×

# How to find PRIME before N and after N ?

 0 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 152●2●4●7 accept rate: 0%

 0 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 73●1●5●8 accept rate: 0%
 0 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 3★junior_g 44●4 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×199
×12
×3
×1
×1

question asked: 22 Oct '12, 00:09

question was seen: 3,951 times

last updated: 17 Apr '17, 19:41