FUNCTION REFERENCE

primes

Prime numbers up to n.

Prime numbers up to n.

Syntax

p = primes(n)

Row vector of the primes not larger than the real scalar n. n below 2 gives a

1-by-0 result.

Example

primes(30)   % 2 3 5 7 11 13 17 19 23 29

Differences from MATLAB: n is limited to 300000000.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.