Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB question

  1. May 17, 2007 #1
    How would I write a program that finds all the prime numbers that are less than or equal to a "user-supplied" integer N, implementing the fact that I should only be dividing N by all prime numbers less than sqrt(N)?
     
  2. jcsd
  3. May 17, 2007 #2

    robphy

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Don't sound like a [strictly-] MATLAB question... but more like a homework problem.

    How would you do it by hand with (say) N=60?
     
  4. May 19, 2007 #3

    Pythagorean

    User Avatar
    Gold Member

    there should be a function that checks whether a resulting calculation is an integer or not (or you can always make your own function).

    That's the key to this.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: MATLAB question
  1. MATLAB questions (Replies: 0)

  2. MATLAB question (Replies: 2)

  3. MATLAB question (Replies: 1)

  4. Matlab question (Replies: 2)

  5. Matlab question (Replies: 10)

Loading...