primesmask

primesmask([lo,] hi)

Returns a prime sieve, as a BitArray, of the positive integers (from lo, if specified) up to hi. Useful when working with either primes or composite numbers.

Examples

julia> primesmask(10)
10-element BitArray{1}:
 0
 0
 1
 1
 0
 1
 0
 1
 0
 0
julia> primesmask(1, 15)
15-element BitArray{1}:
 0
 0
 1
 1
 0
 1
 0
 1
 0
 0
 0
 1
 0
 1
 0
julia> primesmask(1, 10^6)
1000000-element BitArray{1}:
 0
 0
 1
 1
 0
 1
 0
 1
 0
 0
 0
 1
 0
 1
 ⋮
 0
 1
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0
 0

Common mistake example:

julia> primesmask(-10)
ERROR: ArgumentError: `lo` (=-10) must be a non-negative integer.

In this example, a negative value is provided for the lo parameter, which results in an ArgumentError. The lo value must be a non-negative integer.

See Also

abs2, beta, binomial, ceil, cell, cross, ctranspose, ctranspose!, cummin, cumprod, cumprod!, cumsum, cumsum!, cumsum_kbn, div, divrem, eigfact, eigfact!, eigmin, eps, erf, erfc, erfcinv, erfcx, erfi, erfinv, exp, exp10, exp2, expm1, exponent, factor, factorial, factorize, floor, gcd, invmod, log, log10, log1p, log2, logspace, max, min, mod, mod1, modf, next, nextpow, nextprod, num, primes, primesmask, prod, realmin, sqrt, sum!, sumabs, sumabs!, sumabs2, sumabs2!,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: