A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The top level ithprime(i) command returns the ith prime. For example, the first ten primes are given by the following sequence:
| (1.1) |
The top level isprime command determines if a given number is prime:
The Divisors command can also verify that a number is prime. If the divisors of a given integer are only 1 and itself, then the number is prime.
| (1.4) |
The SumOfDivisors command returns the sum of the divisors of an integer:
The top level ifactor command gives the integer factorization of an integer:
The PrimeFactors command returns a list of factors for a given integer that are primes without multiplicity:
The NumberOfPrimeFactors command returns the number of Prime Factors of an integer, counted with multiplicity:
The top level nextprime (or prevprime) commands return the next (or previous) prime number after (or before) the given integer:
The PrimeCounting command returns the number of primes less than a given integer:
Two integers are relatively prime (coprime) if their greatest common divisor (gcd) is 1. The AreCoprime command tests if a sequence of integers or Gaussian integers are coprime:
The following plot shows the coprimes for the integers 1 to 15:
An integer is called square-free if it is not divisible by the square of another number other than 1. All prime numbers are square-free:
|
Mersenne Primes
|
|
Mersenne Primes are prime numbers that are one less than a power of 2. These are numbers of the form:
, where n is a positive integer.
The IthMersenne(i) command returns the exponent for the ith Mersenne prime number:
The nextprime command returns the next prime number after the current value.
The IsMersenne(n) command checks if a positive integer, n, is a Mersenne exponent such that is a Mersenne prime:
|