?

Log in

No account? Create an account
Programming problem: Given an integer N, find the smallest prime >= N. - Adventures in Engineering
The wanderings of a modern ronin.

Ben Cantrick
  Date: 2009-11-11 01:53
  Subject:   Programming problem: Given an integer N, find the smallest prime >= N.
Public

http://www.gully.org/~mackys/findprime.c.txt

http://www.reddit.com/r/coding/comments/a3659/a_coding_challenge_given_an_integer_n_find_the/c0fmqtf

This was mostly interesting to me from a mathematical perspective. I was surprised and gratified to find out that there was such a simple and easy upper bound for pi(x). Also, the 6k+1/6k+5 optimization.

When I first read this problem, my intuition told me that there was a prime between N and 2N. Couldn't prove it if my life depended on it, but somehow I just knew... and lo and behold: http://en.wikipedia.org/wiki/Bertrand%27s_postulate !
Post A Comment | | Link






browse
May 2015