You are not logged in. Please login at www.codechef.com to post your questions!

×

How to find PRIME before N and after N ?

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

master_pk's gravatar image

3★master_pk
152247
accept rate: 0%


You need Sieve of Eratosthenes algorhitm. you can this view here: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

link

answered 22 Oct '12, 00:17

lashabuxo's gravatar image

3★lashabuxo
73158
accept rate: 0%

link
This answer is marked "community wiki".

answered 17 Apr '17, 19:40

junior_g's gravatar image

3★junior_g
444
accept rate: 0%

wikified 17 Apr '17, 19:41

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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