Skip to Main Content Skip to Search
Product Documentation

primes - Generate list of prime numbers

Syntax

p = primes(n)

Description

p = primes(n) returns a row vector of the prime numbers less than or equal to n. A prime number is one that has no factors other than 1 and itself.

Examples

p = primes(37)

p = 2  3  5  7  11  13  17  19  23  29  31  37

See Also

factor

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS