number_primecount Number number_primorial

Number >> Number > number_primes

number_primes

Computes the list of all primes up to n.

Calling Sequence

result = number_primes ( n )
result = number_primes ( n , method )

Parameters

n :

a 1x1 matrix of floating point integers, must be positive, the maximum integer.

method :

a 1x1 matrix of strings, the algorithm to use.

result :

a nx1 matrix of floating point integers, the primes

Description

Returns the list of all primes from 1 up to n, as a row matrix.

The list of algorithms is the following.

"erathostenefast"

Uses a fast Erathostene's Sieve. This implementation is due to Farid BELAHCENE. It requires a lot of memory and may fail if n is too large.

"erathostenenaive"

Uses a naive Erathostene's Sieve. It requires a lot of memory and may fail if n is too large.

Examples

expected = [2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 ...
53 59 61 67 71 73 79 83 89 97];
computed = number_primes ( 100 )
computed = number_primes ( 100 , "erathostenefast" )
computed = number_primes ( 100 , "erathostenenaive" )

Authors

number_primecount Number number_primorial