Skip to main content
\(\newcommand{\set}[1]{\{1,2,\dotsc,#1\,\}} \newcommand{\ints}{\mathbb{Z}} \newcommand{\posints}{\mathbb{N}} \newcommand{\rats}{\mathbb{Q}} \newcommand{\reals}{\mathbb{R}} \newcommand{\complexes}{\mathbb{C}} \newcommand{\twospace}{\mathbb{R}^2} \newcommand{\threepace}{\mathbb{R}^3} \newcommand{\dspace}{\mathbb{R}^d} \newcommand{\nni}{\mathbb{N}_0} \newcommand{\nonnegints}{\mathbb{N}_0} \newcommand{\dom}{\operatorname{dom}} \newcommand{\ran}{\operatorname{ran}} \newcommand{\prob}{\operatorname{prob}} \newcommand{\Prob}{\operatorname{Prob}} \newcommand{\height}{\operatorname{height}} \newcommand{\width}{\operatorname{width}} \newcommand{\length}{\operatorname{length}} \newcommand{\crit}{\operatorname{crit}} \newcommand{\inc}{\operatorname{inc}} \newcommand{\HP}{\mathbf{H_P}} \newcommand{\HCP}{\mathbf{H^c_P}} \newcommand{\GP}{\mathbf{G_P}} \newcommand{\GQ}{\mathbf{G_Q}} \newcommand{\AG}{\mathbf{A_G}} \newcommand{\GCP}{\mathbf{G^c_P}} \newcommand{\PXP}{\mathbf{P}=(X,P)} \newcommand{\QYQ}{\mathbf{Q}=(Y,Q)} \newcommand{\GVE}{\mathbf{G}=(V,E)} \newcommand{\HWF}{\mathbf{H}=(W,F)} \newcommand{\bfC}{\mathbf{C}} \newcommand{\bfG}{\mathbf{G}} \newcommand{\bfH}{\mathbf{H}} \newcommand{\bfF}{\mathbf{F}} \newcommand{\bfI}{\mathbf{I}} \newcommand{\bfK}{\mathbf{K}} \newcommand{\bfP}{\mathbf{P}} \newcommand{\bfQ}{\mathbf{Q}} \newcommand{\bfR}{\mathbf{R}} \newcommand{\bfS}{\mathbf{S}} \newcommand{\bfT}{\mathbf{T}} \newcommand{\bfNP}{\mathbf{NP}} \newcommand{\bftwo}{\mathbf{2}} \newcommand{\cgA}{\mathcal{A}} \newcommand{\cgB}{\mathcal{B}} \newcommand{\cgC}{\mathcal{C}} \newcommand{\cgD}{\mathcal{D}} \newcommand{\cgE}{\mathcal{E}} \newcommand{\cgF}{\mathcal{F}} \newcommand{\cgG}{\mathcal{G}} \newcommand{\cgM}{\mathcal{M}} \newcommand{\cgN}{\mathcal{N}} \newcommand{\cgP}{\mathcal{P}} \newcommand{\cgR}{\mathcal{R}} \newcommand{\cgS}{\mathcal{S}} \newcommand{\bfn}{\mathbf{n}} \newcommand{\bfm}{\mathbf{m}} \newcommand{\bfk}{\mathbf{k}} \newcommand{\bfs}{\mathbf{s}} \newcommand{\bijection}{\xrightarrow[\text{onto}]{\text{$1$--$1$}}} \newcommand{\injection}{\xrightarrow[]{\text{$1$--$1$}}} \newcommand{\surjection}{\xrightarrow[\text{onto}]{}} \newcommand{\nin}{\not\in} \newcommand{\prufer}{\mbox{prüfer}} \DeclareMathOperator{\fix}{fix} \DeclareMathOperator{\stab}{stab} \DeclareMathOperator{\var}{var} \newcommand{\inv}{^{-1}} \newcommand{\lt}{ < } \newcommand{\gt}{ > } \newcommand{\amp}{ & } \)

Section1.4Combinatorics and Number Theory

Broadly, number theory concerns itself with the properties of the positive integers. G.H. Hardy was a brilliant British mathematician who lived through both World Wars and conducted a large deal of number-theoretic research. He was also a pacifist who was happy that, from his perspective, his research was not “useful”. He wrote in his 1940 essay A Mathematician's Apology “[n]o one has yet discovered any warlike purpose to be served by the theory of numbers or relativity, and it seems very unlikely that anyone will do so for many years.” 1  Little did he know, the purest mathematical ideas of number theory would soon become indispensable for the cryptographic techniques that kept communications secure. Our subject here is not number theory, but we will see a few times where combinatorial techniques are of use in number theory.


Form a sequence of positive integers using the following rules. Start with a positive integer \(n>1\). If \(n\) is odd, then the next number is \(3n+1\). If \(n\) is even, then the next number is \(n/2\). Halt if you ever reach \(1\). For example, if we start with \(28\), the sequence is \begin{equation*} 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1. \end{equation*}

Now suppose you start with \(19\). Then the first few terms are \begin{equation*} 19, 58, 29, 88, 44, 22. \end{equation*} But now we note that the integer \(22\) appears in the first sequence, so the two sequences will agree from this point on. Sequences formed by this rule are called Collatz sequences.

Pick a number somewhere between \(100\) and \(200\) and write down the sequence you get. Regardless of your choice, you will eventually halt with a \(1\). However, is there some positive integer \(n\) (possibly quite large) so that if you start from \(n\), you will never reach \(1\)?


Students in middle school are taught to add fractions by finding least common multiples. For example, the least common multiple of \(15\) and \(12\) is \(60\), so: \begin{equation*} \frac{2}{15}+ \frac{7}{12} = \frac{8}{60}+\frac{35}{60} = \frac{43}{60}. \end{equation*} How hard is it to find the least common multiple of two integers?

It's really easy if you can factor them into primes. For example, consider the problem of finding the least common multiple of \(351785000\) and \(316752027900\) if you just happen to know that \begin{align*} 351785000 \amp = 2^3\times 5^4\times 7\times19\times 23^2\quad\text{and}\\ 316752027900 \amp = 2^2\times3\times 5^2\times 7^3\times 11\times 23^4. \end{align*} Then the least common multiple is \begin{equation*} 300914426505000 = 2^3\times3\times 5^4\times 7^3\times 11\times 19\times 23^4. \end{equation*}

So to find the least common multiple of two numbers, we just have to factor them into primes. That doesn't sound too hard. For starters, can you factor \(1961\)? OK, how about \(1348433\)? Now for a real challenge. Suppose you are told that the integer \begin{align*} c = \amp\,\, 5568490117077035708244283173335040521716369235589951150965\\ \amp\,\, 2043138898236817075547572153799 \end{align*} is the product of two primes \(a\) and \(b\). Can you find them?

What if factoring is hard? Can you find the least common multiple of two relatively large integers, say each with about \(500\) digits, by another method? How should middle school students be taught to add fractions?

As an aside, we note that most calculators can't add or multiply two \(20\) digits numbers, much less two numbers with more than \(500\) digits. But it is relatively straightforward to write a computer program that will do the job for us. Also, there are some powerful mathematical software tools available. Two very well known commercial examples are Maple® and Mathematica®. In this text, we will from time to time, make use of the open source computer algebra system SageMath. We will sometimes embed interactive SageMath cells in the text, but you can also use SageMath for free online via the SageMath Cloud. For example, the SageMath cell below will produce the factorization shown above.

If you're reading this text in a web browser, go ahead and change the integer in the SageMath cell above to some other, perhaps larger, integer and click the button again to get the prime factorization of your new integer.

Now here's how we made up the challenge problem. First, we found a site on the web that lists large primes and found these two values: \begin{align*} a \amp = 2425967623052370772757633156976982469681\quad\text{and}\\ b \amp = 22953686867719691230002707821868552601124472329079. \end{align*} The SageMath code below calculates \(a\times b\), and returns the result instantly.

On the other hand, if you ask SageMath to factor \(c\), as in the cell below, you'll likely be waiting a long time. If you get a response in more than a couple of minutes, please email us so that we can update the text with larger primes \(a\) and \(b\)!

Questions arising in number theory can also have an enumerative flair, as the following example shows.


In Table 1.11, we show the integer partitions of \(8\).

8 distinct parts 7+1 distinct parts, odd parts 6+2 distinct parts
6+1+1 5+3 distinct parts, odd parts 5+2+1 distinct parts
5+1+1+1 odd parts 4+4 4+3+1 distinct parts
4+2+2 4+2+1+1 4+1+1+1+1
3+3+2 3+3+1+1 odd parts 3+2+2+1
3+2+1+1+1 3+1+1+1+1+1 odd parts 2+2+2+2
2+2+2+1+1 2+2+1+1+1+1 2+1+1+1+1+1+1
1+1+1+1+1+1+1+1 odd parts
Table1.11The partitions of \(8\), noting those into distinct parts and those into odd parts.

There are \(22\) partitions altogether, and as noted, exactly \(6\) of them are partitions of \(8\) into odd parts. Also, exactly \(6\) of them are partitions of \(8\) into distinct parts.

What would be your reaction if we asked you to find the number of integer partitions of \(25892\)? Do you think that the number of partitions of \(25892\) into odd parts equals the number of partitions of \(25892\) into distinct parts? Is there a way to answer this question without actually calculating the number of partitions of each type?