its computers


NumTh is a Number Theory library developed in Python 3. It is still a work in progress, with more features and tests being added regularly. Check out some interesting number facts generated by the library!

interesting numbers

Some of the features include:

  • Euclidean algorithm
  • Bezout's Lemma
  • Modular inverse
  • Jacobi/Lagrange symbol
  • Primality testing
  • Miller-Rabin primality testing
  • Lucas primality testing
  • Prime generation
  • Twin prime generation
  • Prime-counting function pi
  • Prime factorization
  • Pollard's rho factorization
  • Pollard's p-1 factorization
  • Divisor list generation
  • Euler's phi function (totient)
  • Carmichael's lambda function
  • Modular square root
  • Rational number arithmetic
  • Rational approximation
  • Square root approximations
  • Continued fraction algorithm
  • Pi approximation
  • Polynomial arithmetic
  • Modular arithmetic
  • Ring extensions by sqrt(D)
  • Quaternion arithmetic
  • Sums of two squares
  • Sums of four squares

Some of the features that I will be adding in the future include:

  • Rational number sieve
  • Algebraic ring extentions
  • Finite field arithmetic
  • Cryptography
  • Elliptic curve arithmetic
  • Elliptic curve primality testing
  • Elliptic curve factorization

The goal of this library is not necessarily to improve on the many already existing and already optimized functions that exist in other packages/languages, but rather to understand how these structures/algorithms are implemented from basic principles.

One of the long-term goals of this library is to build an interactive online tool for learning computational Number Theory, both theoretically and programmatically. This educational aspect will develop concurrently with the further improvements and additions to the library.

Visit to view the source code of this currently unfinished, but in-progress, python library. And please contact me if you have suggestions or critiques regarding the library!