# Polygonal Numbers
> EYPHKA! num = (triangle) + (triangle) + (triangle)
>
> Carl Friedrich Gauss
## Introduction
### Triangular numbers
T0 = 0
.
T1 = 1
.
. .
T2 = 3
.
. .
. . .
T3 = 6
(...)
### Square numbers
S0 = 0
.
S1 = 1
..
..
S2 = 4
...
...
...
S3 = 9
(...)
### General case
The formula for the n-th s-gonal number is
P(s,n) = [(s-2)*n^2 - (s-4)*n] / 2
## Fermat polygonal number theorem
Thm. Every positive integer is a sum of at most n n-gonal numbers.
For example,
27
= 21 + 6 + 0 (Triangular)
= 16 + 9 + 1 + 1 (Square)
= 22 + 5 + 0 + 0 + 0 (Pentagonal)
= 15 + 6 + 6 + 0 + 0 + 0 (Hexagonal)
...
n=4 case is especially famous. It is called Lagrange's four-square
theorem.