Skip to content

primes

specfun · scripts/specfun/primes.m

: p = primes (n)
: p = primes (n, "twin")

Row vector of all prime numbers not exceeding the real scalar n, in ascending order. A non-integer n is rounded down. The result has the class of n for single and integer classes.

With the second argument "twin", return an m-by-2 matrix of twin-prime pairs [p, p+2] where both members are primes not exceeding n. When no such pair exists the result is empty with size [0, 2].