An ancient result states that a triangle with vertices $A$, $B$ and $C$ with lengths $AB=a$, $BC=b$ and $AC=c$ is right angled at $B$ iﬀ ${a}^{2}+{b}^{2}={c}^{2}$. The fact that ${a}^{2}+{b}^{2}={c}^{2}$ is a necessary condition for the right angle is the famous Pythagoras theorem. However, it is also a suﬃcient condition for the triangle to be a right angle. In fact, it is known that

- (i)
- a triangle is obtuse at $B$ iﬀ ${a}^{2}+{b}^{2}<{c}^{2}$;
- (ii)
- a triangle is right angles at $B$ iﬀ ${a}^{2}+{b}^{2}={c}^{2}$;
- (iii)
- a triangle is acute at $B$ iﬀ ${a}^{2}+{b}^{2}>{c}^{2}$.

In all the above cases the suﬃciency can be proved using the law of cosines. An important application of above result is that it can used to construct right angles (say in a construction of a building).

What are all the integer triples $a,b,c\in \mathbb{Z}$ for which ${a}^{2}+{b}^{2}={c}^{2}$? For instance, $\left(1,1,2\right)$ is not a integer triple that solves ${a}^{2}+{b}^{2}={c}^{2}$. Note that if a integer triple $\left(a,b,c\right)$ solves ${a}^{2}+{b}^{2}={c}^{2}$ then all combinations of $\left(\pm a,\pm b,\pm c\right)$ are also integer triple. Therefore, it is enough to look for non-negative integer triples $\left(a,b,c\right)$. Further, $\left(0,1,1\right)$ and $\left(1,0,1\right)$ is also a trivial integer solution which will not represent a triangle. A positive integer triple $\left(a,b,c\right)$ is said to be Pythagorean triple if ${a}^{2}+{b}^{2}={c}^{2}$. Note that if $\left(a,b,c\right)$ is a Pythagorean triple then $ka,kb,kc)$ is also a Pythagorean triple for all $k\in \mathbb{N}$. For instance, $\left(3,4,5\right)$ is a Pythagorean triple then $\left(6,8,10\right)$ (multiplied by $2$) is also a Pythagorean triple. This corresponds to the case similar right triangles. A Pythagorean triple $\left(a,b,c\right)$ is said to be primitve if $\mathrm{\text{gcd}}\left(a,b,c\right)=1$, i.e., $a,b,c$ have no common factors, except $1$, among them. This is equivalent to saying that $\mathrm{\text{gcd}}\left(a,b\right)=1$ because whatever divides LHS will also divide RHS. For instance, $\left(3,4,5\right)$ and $\left(5,12,13\right)$ are both primitive Pythagorean triple (PPT).

As we have already noted, there are integer triples that are not PPT. For instance, $\left(1,2,3\right)$ is not a PPT. Therefore, two natural questions are:

- (i)
- How many PPT’s are there, ﬁnite or inﬁnite?
- (ii)
- Is it possible to generate all PPT’s?

It turns out that there are inﬁnitely many PPT’s and the answer to second question is in aﬃrmative.

Theorem 1. If $\left(a,b,c\right)$ is a PPT then $c$ is always an odd number and, between $a$ and $b$, one is even and the other odd.

Proof. Since $\mathrm{\text{gcd}}\left(a,b\right)=1$ both cannot be even. Suppose both and $a$ and $b$ are odd, then $a=2k+1$ and $b=2l+1$. Therefore ${a}^{2}$ and ${b}^{2}$ are also odd because square of an odd number is odd (Use ${\left(2k+1\right)}^{2})$!). Therefore ${a}^{2}+{b}^{2}$ is even because sum of odd numbers is even. Thus ${c}^{2}$ is even and, hence $c$ is even. Let $c=2m$. Then

$$\begin{array}{rcll}4{k}^{2}+4k+1+4{l}^{2}+4l+1& =& 4{m}^{2}& \text{}\\ 2\left({k}^{2}+{l}^{2}+k+l\right)+1& =& 2{m}^{2}.& \text{}\end{array}$$Note that LHS is odd and RHS is even which is a contradiction. Therefore, one of $a$ and $b$ is even and the other odd. This implies ${c}^{2}$ is odd and, hence, $c$ is odd. □

The above result rules out all triples $\left(a,b,c\right)$, with $c$ even, as a possible PPT. It is enough to consider $c$ odd. But that still does not say all odd $c$ are allowed. For instance, there is no choice of $\left(a,b\right)\in \mathbb{N}$ such that $\left(a,b,3\right)$ is a PPT. In fact, the ﬁrst PPT is $\left(3,4,5\right)$.

Also owing to the result above, henceforth in the pair $\left(a,b\right)$, we shall always denote the odd number by $a$ and the even number by $b$. For any PPT $\left(a,b,c\right)$, we write ${a}^{2}={c}^{2}-{b}^{2}=\left(c+b\right)\left(c-b\right)$. Note that $c-b>0$.

Proof. Let $x\in \mathbb{N}$ divide both $c+b$ and $c-b$. Then $c+b=kx$ and $c-b=lx$ for some $k,l\in \mathbb{N}$. Then $2c=x\left(k+l\right)$ and $2b=x\left(k-l\right)$ which means that $x$ divides both $2b$ and $2c$. But $\mathrm{\text{gcd}}\left(b,c\right)=1$ and, hence, $x=1$ or $x=2$. Since $x$ should also divide ${a}^{2}$, hence $a$. But $a$ is odd so $x=1$. □

Above result says that ${a}^{2}$, a perfect square, is product of two relatively prime numbers $c+b$ and $c-b$. Let $c+b={p}_{1}^{{x}_{1}}\dots {p}_{k}^{{x}_{k}}$ and $c-b={q}_{1}^{{y}_{1}}\dots {q}_{l}^{{y}_{l}}$ be the respective unique prime decomposition. Then ${a}^{2}={p}_{1}^{{x}_{1}}\dots {p}_{k}^{{x}_{k}}{q}_{1}^{{y}_{1}}\dots {q}_{l}^{{y}_{l}}$. Since $c+b$ and $c-b$ are relatively prime ${p}_{i}\ne {q}_{j}$ for all $i,j$. Thus, each ${x}_{i}$ and ${y}_{j}$ is even. Therefore, $c+b$ and $c-b$ are also perfect squares, say $c+b={m}^{2}$ and $c-b={n}^{2}$, for some $m,n\in \mathbb{N}$ such that $m>n$ and $\mathrm{\text{gcd}}\left(m,n\right)=1$. Consequently, $a=mn$ and, since $a$ is odd, both $m$ and $n$ are odd. So, for every choice of odd positive integer $m,n$ such that $m>n$ and $\mathrm{\text{gcd}}\left(m,n\right)=1$, we have a PPT $\left(a,b,c\right)$ given by $a=mn$, $b=\frac{{m}^{2}-{n}^{2}}{2}$ and $c=\frac{{m}^{2}+{n}^{2}}{2}$. The last two equalities are obtained by solving for $b$ and $c$ using $c+b={m}^{2}$ and $c-b={n}^{2}$. Since there are inﬁnitely many choices of $m,n$ satisfying above condition there are inﬁnitely many PPT’s.

A generalisation of the Pythagorean triple condition is, for a ﬁxed integer $n>2$, seeking triples $\left(a,b,c\right)$ such that ${a}^{n}+{b}^{n}={c}^{n}$. Obviously, there are some trivial solution if $\left(a,b,c\right)$ is such that $abc=0$. However, it turns out there are no non-trivial solution, i.e., $\left(a,b,c\right)$ with $abc\ne 0$

Theorem 3 (Fermat’s Last Theorem). Given an integer $n>2$, there are no integer solutions to ${a}^{n}+{b}^{n}={c}^{n}$ with $abc\ne 0$.

Suppose $n=kl$. Then if the equation ${a}^{n}+{b}^{n}={c}^{n}$ has integer solution then, using ${\left({a}^{k}\right)}^{l}+{\left({b}^{k}\right)}^{l}={\left({c}^{k}\right)}^{l}$, $\left({a}^{k},{b}^{k},{c}^{k}\right)$ is a solution corresponding to $n=l$. Therefore, to prove FLT it is enough to prove the result for $l\le n$. Note that any $n>2$ is:

- 1.
- either $n={2}^{m}$, for some integer $m>2$, which is same as $n=4\times {2}^{k-2}$. Choose $l=4$ in this case;
- 2.
- or an odd prime. Choose $l=n$ in this case;
- 3.
- or a muliple of an odd prime. Choose $l$ to be the odd prime.

Thus, it is enough to prove the result for $n=4$ and odd prime $n$. If there is an integer solution to ${a}^{4}+{b}^{4}={c}^{4}$ then $\left(a,b,{c}^{2}\right)$ is an integer solution to ${x}^{4}+{y}^{4}={z}^{2}$. So, to prove FLT for $n=4$ we show the following theorem:

Proof. Suppose there is a integer triple $\left(x,y,z\right)$ such that $xyz\ne 0$ solving ${x}^{4}+{y}^{4}={z}^{2}$. Without loss of generality, we may assume that $x,y,z$ are all positive, $\mathrm{\text{gcd}}\left(x,y,z\right)=1$ and, hence, $\mathrm{\text{gcd}}\left(x,y\right)=1$.

(Step 1): Note that $\left({x}^{2},{y}^{2},z\right)$ is a PPT, since $\mathrm{\text{gcd}}\left({x}^{2},{y}^{2},z\right)=1$ (if necessary, we rewrite $x$ and $y$ such that ${x}^{2}$ is odd and ${y}^{2}$ is even). We also know that $z$ is always odd.

(Step 2): There exists odd numbers $m,n\in \mathbb{N}$, such that $m>n$, $\mathrm{\text{gcd}}\left(m,n\right)=1$ and

Then, $2{y}^{2}={m}^{2}-{n}^{2}=\left(m+n\right)\left(m-n\right)$. Since $m$ and $n$ are odd, both $m+n$ and $m-n$ are even and, hence, are not coprime.

(Step 3): Let $d>1$ divide both $m+n$ and $m-n$. Then $m+n=kd$ and $m-n=ld$ for some $k,l\in \mathbb{N}$. Then $2m=d\left(k+l\right)$ and $2n=d\left(k-l\right)$ which means that $d$ divides both $2m$ and $2n$. But $\mathrm{\text{gcd}}\left(m,n\right)=1$ therefore $d$ divides $2$. Therefore, $d=2$. Hence, $m+n=2k$, $m-n=2l$, $m=k+l$ and $n=k-l$. Since $\mathrm{\text{gcd}}\left(m+n,m-n\right)=2$, $\mathrm{\text{gcd}}\left(k,l\right)=1$.

(Step 4): In fact, using the equation of ${x}^{2}$, we have ${x}^{2}+{l}^{2}={k}^{2}$, i.e., $\left(x,l,k\right)$ is a PPT. Therefore, $l$ is even and $k$ is odd. Let $l=2\ell $. Then $\mathrm{\text{gcd}}\left(k,\ell \right)=1$.

(Step 5): Using equation for ${y}^{2}$, we get $2{y}^{2}=4kl=8k\ell $, i.e., ${y}^{2}=4k\ell $. Hence $k$ and $\ell $ are perfect squares, $k={u}^{2}$ and $\ell ={v}^{2}$ and $\mathrm{\text{gcd}}\left(u,v\right)=1$. Therefore, $\left(x,2{v}^{2},{u}^{2}\right)$ is a PPT.

We repeat Step 2 on $\left(x,2{v}^{2},{u}^{2}\right)$. There exists odd numbers $M,N\in \mathbb{N}$, such that $M>N$ and $\mathrm{\text{gcd}}\left(M,N\right)=1$ we have

We repeat Step 3 on $M+N$ and $M-N$ to obtain $K$ and $L$ such that $\mathrm{\text{gcd}}\left(K,L\right)=1$, $M+N=2K$, $M-N=2L$, $M=K+L$ and $N=K-L$.

We repeat Step 5 on $2{v}^{2}$ to conclude that ${v}^{2}=KL$ and, hence, $K={U}^{2}$ and $L={V}^{2}$ and $\mathrm{\text{gcd}}\left(U,V\right)=1$.

Using the value of $M$ and $N$ in the equation of ${u}^{2}$, we get

$$\begin{array}{rcll}{u}^{2}& =& \frac{{M}^{2}+{N}^{2}}{2}& \text{}\\ & =& \frac{2\left({K}^{2}+{L}^{2}\right)}{2}={U}^{4}+{V}^{4}.& \text{}\end{array}$$Therefore, $\left(U,V,u\right)$ is also a non-trivial integer solution of ${x}^{4}+{y}^{4}={z}^{2}$. Let us compare the two solutions $\left(x,y,z\right)$ and $\left(U,V,u\right)$. Note that

This implies that ${u}^{4}<z$, hence $u<z$. Thus, when we started with a non-trivial solution $\left(x,y,z\right)$ we obtained another non-trivial solution $\left(U,V,u\right)$ such that $0<u<z$. We can repeat the entire proof for again for $\left(U,V,u\right)$ playing the role of $\left(x,y,z\right)$ above and can obtain another non-trivial solution ${U}_{1},{V}_{1},{u}_{1})$ such that $0<{u}_{1}<u<z$. This is a contradiction because we cannot carry on inﬁnite number of times as suggested by our proof. Therefore, our assumption on the existence of a non-trivial integer solution is false. □

With all the eﬀort above, it only remains to prove the Fermat’s Last theorem for odd primes.

Theorem 5 (Fermat’s Last Theorem). Given an odd prime $p$, there are no integer solutions to ${a}^{p}+{b}^{p}={c}^{p}$ with $abc\ne 0$.

Deﬁnition 1. An odd prime number $p$ is called regular if $p$ does not divide the numerator of the Bernoulli number ${B}_{k}$, for all even $k\le p-3$. Any odd prime which is not regular is called irregular.

The odd primes $3,5,7,\dots ,31$ are all regular primes. The ﬁrst irregular prime is $37$. It is an open question: are there inﬁnitely many regular primes? However, it is known that there are inﬁnitely many irregular primes.

Theorem 6 (Kummer, 1850). If $p$ is a regular odd prime then the equation

has no solution in $\mathbb{N}$.

Gerhard Frey proved the following result related to FLT:

Theorem 7 (Proved in 1984). Given a odd prime $p$ if there exists a non-trivial solution to the equation

then the following elliptic curve, called Frey’s curve, must exist:

So, what is an elliptic curve? Given $a,b,c\in \mathbb{Z}$, consider plane curve of the form ${y}^{2}={x}^{3}+a{x}^{2}+bx+c$. Let us call it $\Gamma $. The discriminant of $\Gamma $ is deﬁned as

The $\Delta =0$ relates to the case when the curve self-intersects, called singular points. A curve $\Gamma $ is said to be an elliptic curve if $\Delta \left(\Gamma \right)\ne 0$. If $\Delta <0$ the curve will divide the plane in two connected components and if $\Delta >0$ it divides the plane into more than two connected components. Elliptic curves are symmetrical about $x$-axis. The points on the elliptic curve form an abelian group under a suitable binary operation ($+$). An elliptic curve $\Gamma $ is modular if there exists a $L$-function of $\Gamma $. In 1955, the Taniyama-Shimura-Weil (TSW) conjectured (also called modularity theorem) states that:

This means if Frey’s curve existed it must be modular. But, in $1985$, Jean-Pierre Serre conjectured (epsilon conjecture) that Frey’s curve is not modular which was later proved by Ken Ribet in $1986$. Since Frey’s curve is an elliptic curve it must be modular assuming TSW conjecture. An elliptic curve is semistable if a prime divides its discriminant and Frey’s curve is semistable. In $1994$-$95$ by Andrew Wiles showed that:

This means Frey’s curve cannot exist and, hence, Fermat’s last theorem is true.