math::numtheory(3tcl) | Tcl Math Library | math::numtheory(3tcl) |
math::numtheory - Number Theory
package require Tcl ?8.5?
package require math::numtheory ?1.1.1?
math::numtheory::isprime N ?option value ...?
math::numtheory::firstNprimes N
math::numtheory::primesLowerThan N
math::numtheory::primeFactors N
math::numtheory::primesLowerThan N
math::numtheory::primeFactors N
math::numtheory::uniquePrimeFactors N
math::numtheory::factors N
math::numtheory::totient N
math::numtheory::moebius N
math::numtheory::legendre a p
math::numtheory::jacobi a b
math::numtheory::gcd m n
math::numtheory::lcm m n
math::numtheory::numberPrimesGauss N
math::numtheory::numberPrimesLegendre N
math::numtheory::numberPrimesLegendreModified N
math::numtheory::differenceNumberPrimesLegendreModified lower upper
This package is for collecting various number-theoretic operations, with a slight bias to prime numbers.
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:
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 [http://core.tcl.tk/tcllib/reportlist]. 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.
number theory, prime
Mathematics
Copyright (c) 2010 Lars Hellström <Lars dot Hellstrom at residenset dot net>
1.1.1 | tcllib |