a repository of mathematical know-how

Computational number theory front page

Quick description

Number theory tells us many beautiful results, but it does not always do so explicitly. For example, if p is a prime number, then the multiplicative group mod p must be cyclic: that is, there must exist some a such that a^{p-1}\equiv 1 mod p but a^r\not\equiv 1 whenever 1\leq a<p-1. But this result is proved by a counting argument that gives no clue about how to find such an a or how to establish that a given number a has that property. Such questions are the domain of computational number theory. There are a number of beautiful tricks in the area that make it particularly well suited to being discussed in the Tricki.


Elementary number theory, and especially modular arithmetic.

Links to articles

Some of the tricks, though clever, are quite simple to explain. As a result, some of the following articles are quite short.

To work out powers mod n, use repeated squaring

To establish that n is composite, show that Fermat's little theorem does not hold for n

To find a factor of n, find some m such that (m,n)\ne 1

To factorize n, find a non-trivial square root of 1 mod n

To find a rational with low denominator near a given real, use continued fractions