Primes
Object providing utility methods related to prime numbers, including generating primes, checking primality, applying mathematical functions, and working with predefined sets of prime numbers and special cases such as Carmichael numbers.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Primes.type
Members list
Value members
Concrete methods
Create a lazy list of BigInts starting with x.
Create a lazy list of BigInts starting with x.
Value parameters
- x
-
the first BigInt that is required.
Attributes
- Returns
-
a LazyList[BigInt] whose head is x.
Generates a list of prime numbers less than or equal to a given upper bound using the Sieve of Eratosthenes algorithm.
Generates a list of prime numbers less than or equal to a given upper bound using the Sieve of Eratosthenes algorithm.
Value parameters
- m
-
the upper bound (inclusive) for the prime numbers to be generated.
Attributes
- Returns
-
a list of prime numbers represented as
Primeobjects, where each prime is less than or equal to the given upper bound.
Method to yield the "prime counting function" aka "piApprox" for a given number. The result is an approximation to the number of primes not greater than x.
Method to yield the "prime counting function" aka "piApprox" for a given number. The result is an approximation to the number of primes not greater than x.
Value parameters
- x
-
the ordinal position in the list of primes of the prime number required.
Attributes
- Returns
-
an approximation to the kth prime number.
Filters and returns a finite list of prime numbers based on a given predicate. Throws a PrimeException if the filter does not yield a finite list of primes.
Filters and returns a finite list of prime numbers based on a given predicate. Throws a PrimeException if the filter does not yield a finite list of primes.
Value parameters
- f
-
the predicate function applied to candidate primes. Only primes for which this function returns
truewill be included in the result.
Attributes
- Returns
-
a finite list of primes that satisfy the given predicate.
- Note
-
Throws PrimeException if the predicate results in an infinite list of primes.
Method to generate a random prime of size bits bits.
Method to generate a random prime of size bits bits.
Value parameters
- bits
-
the size of the resulting Prime in bits.
Attributes
- Returns
-
a Prime number with certainly 2.pow(-100).
Method to yield a lazy list of all probable primes smaller than x.
Method to yield a lazy list of all probable primes smaller than x.
Attributes
- Returns
-
a LazyList[Prime].
Concrete fields
Method to yield a lazy list of all probable primes.
Method to yield a lazy list of all probable primes.
Attributes
- Returns
-
a LazyList[Prime].
The first Carmichael numbers, i.e numbers which satisfy Fermat's little theorem but are composite.
The first Carmichael numbers, i.e numbers which satisfy Fermat's little theorem but are composite.
Attributes
The first 100 true primes.
The first 100 true primes.