Results 1 to 3 of 3

Math Help - Greatest prime less than N

  1. #1
    Member
    Joined
    Nov 2010
    Posts
    95

    Greatest prime less than N

    Hi, one way to do it is by sieve's technique but is there any other method?
    Thanks.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Joined
    Aug 2007
    From
    USA
    Posts
    3,110
    Thanks
    2
    Sure! You can test every value, instead. I'd start at N, rather than 1.

    What sort of "other method" did you have in mind?
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Apr 2011
    Posts
    3
    Two points.
    With any method, since there is always at least one prime between N and 2N, start from N and decrement, when you reach N/2. if N is prime, you save time. in this case the largest prime lesss than N is 1.
    If N is large, the divide test will be tedious. Use a primalty test (Rabin, or Lucas or else. It will be much faster
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 1
    Last Post: October 22nd 2011, 12:37 PM
  2. Replies: 1
    Last Post: June 19th 2011, 12:56 PM
  3. Replies: 6
    Last Post: August 27th 2010, 11:44 PM
  4. greatest value
    Posted in the Algebra Forum
    Replies: 4
    Last Post: September 3rd 2009, 07:31 AM
  5. Finding the greatest prime factor:
    Posted in the Math Topics Forum
    Replies: 11
    Last Post: May 21st 2007, 07:52 PM

Search Tags


/mathhelpforum @mathhelpforum