Computes the list of all primes up to n.
result = number_primes ( n ) result = number_primes ( n , method )
a 1x1 matrix of floating point integers, must be positive, the maximum integer.
a 1x1 matrix of strings, the algorithm to use.
a nx1 matrix of floating point integers, the primes
Returns the list of all primes from 1 up to n, as a row matrix.
The list of algorithms is the following.
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.
Uses a naive Erathostene's Sieve. It requires a lot of memory and may fail if n is too large.
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" )