math::numtheory - Number Theory
This package is for collecting various number-theoretic operations, with a slight bias to prime numbers.
The isprime command tests whether the integer N is a prime, returning a boolean true value for prime N and a boolean false value for non-prime N. The formal definition of 'prime' used is the conventional, that the number being tested is greater than 1 and only has trivial divisors.
To be precise, the return value is one of 0 (if N is definitely not a prime), 1 (if N is definitely a prime), and on (if N is probably prime); the latter two are both boolean true values. The case that an integer may be classified as "probably prime" arises because the Miller-Rabin algorithm used in the test implementation is basically probabilistic, and may if we are unlucky fail to detect that a number is in fact composite. Options may be used to select the risk of such "false positives" in the test. 1 is returned for "small" N (which currently means N < 118670087467), where it is known that no false positives are possible.
The only option currently defined is:
Unknown options are silently ignored.
Return the first N primes
Number of primes to return
Return the prime numbers lower/equal to N
Maximum number to consider
Return a list of the prime numbers in the number N
Number to be factorised
Return the prime numbers lower/equal to N
Maximum number to consider
Return a list of the prime numbers in the number N
Number to be factorised
Return a list of the unique prime numbers in the number N
Number to be factorised
Return a list of all unique factors in the number N, including 1 and N itself
Number to be factorised
Evaluate the Euler totient function for the number N (number of numbers relatively prime to N)
Number in question
Evaluate the Moebius function for the number N
Number in question
Evaluate the Legendre symbol (a/p)
Upper number in the symbol
Lower number in the symbol (must be non-zero)
Evaluate the Jacobi symbol (a/b)
Upper number in the symbol
Lower number in the symbol (must be odd)
Return the greatest common divisor of m and n
First number
Second number
Return the lowest common multiple of m and n
First number
Second number
Estimate the number of primes according the formula by Gauss.
Number in question, should be larger than 0
Estimate the number of primes according the formula by Legendre.
Number in question, should be larger than 0
Estimate the number of primes according the modified formula by Legendre.
Number in question, should be larger than 0
Estimate the number of primes between tow limits according the modified formula by Legendre.
Lower limit for the primes, should be larger than 0
Upper limit for the primes, should be larger than 0
Return a list of pairs of primes each differing by the given step.
Lower limit for the primes, should be larger than 0
Upper limit for the primes, should be larger than the lower limit
Step by which the primes should differ, defaults to 2
Return a list of lists of primes each differing by the given step from the previous one.
Lower limit for the primes, should be larger than 0
Upper limit for the primes, should be larger than the lower limit
Step by which the primes should differ, defaults to 2
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category math :: numtheory of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.
Mathematics
Copyright © 2010 Lars Hellström <Lars dot Hellstrom at residenset dot net>