**31** (**thirty-one**) is the natural number following 30 and preceding 32.

Thirty-one is the third Mersenne prime (2^{5} − 1) and the eighth Mersenne prime exponent, as well as the fourth primorial prime, and together with twenty-nine, another primorial prime, it comprises a twin prime. As a Mersenne prime, 31 is related to the perfect number 496, since 496 = 2^{(5 − 1)}(2^{5} − 1). 31 is also the 4th lucky prime and the 11th supersingular prime.

31 is a centered triangular number, the lowest prime centered pentagonal number and a centered decagonal number.

For the Steiner tree problem, 31 is the number of possible Steiner topologies for Steiner trees with 4 terminals.

At 31, the Mertens function sets a new low of −4, a value which is not subceded until 110.

No integer added up to its base 10 digits results in 31, making 31 a self number.

31 is a repdigit in base 5 (111), and base 2 (11111).

The numbers 31, 331, 3331, 33331, 333331, 3333331, and 33333331 are all prime. For a time it was thought that every number of the form 3_{w}1 would be prime. However, the next nine numbers of the sequence are composite; their factorisations are:

333333331 = 17 × 19607843
3333333331 = 673 × 4952947
33333333331 = 307 × 108577633
333333333331 = 19 × 83 × 211371803
3333333333331 = 523 × 3049 × 2090353
33333333333331 = 607 × 1511 × 1997 × 18199
333333333333331 = 181 × 1841620626151
3333333333333331 = 199 × 16750418760469 and
33333333333333331 = 31 × 1499 × 717324094199.
The recurrence of the factor 31 in the last number above can be used to prove that no sequence of the type R_{w}E or ER_{w} can consist only of primes because every prime in the sequence will periodically divide further numbers. Here, 31 divides every fifteenth number in 3_{w}1 (and 331 every 110th).

The atomic number of gallium
Messier object M31, a magnitude 4.5 galaxy in the constellation Andromeda. It is also known as the Andromeda Galaxy, and is readily visible to the naked eye in a modestly dark sky.
The New General Catalogue object NGC 31, a spiral galaxy in the constellation Phoenix
The Saros number of the solar eclipse series which began on -1805 January 31 and ended on -489 March 31 (*see Astronomical year numbering*). The duration of Saros series 31 was 1316.2 years, and it contained 74 solar eclipses.
The Saros number of the lunar eclipse series which began on -1774 May 30 and ended on -476 July 17. The duration of Saros series 31 was 1298.1 years, and it contained 73 lunar eclipses.
The jersey number 31 has been retired by several North American sports teams in honor of past playing greats:

In Major League Baseball:
The San Diego Padres, for Dave Winfield.
The Chicago Cubs, for Ferguson Jenkins and Greg Maddux.
The Atlanta Braves, also for Maddux.
The New York Mets, for Mike Piazza.
In the NBA:
The Boston Celtics, for Cedric Maxwell.
The Indiana Pacers, for Reggie Miller.
In the NHL:
The Edmonton Oilers, for Grant Fuhr.
The New York Islanders, for Billy Smith.
In the NFL:
The Atlanta Falcons, for William Andrews.
The New Orleans Saints, for Jim Taylor.
NASCAR driver Jeff Burton drives #31, a car which was subject to a controversy when one of the sponsors changed its name after merging with another company.

In ice hockey goaltenders often wear the number 31.

In football the number 31 has been retired by Queens Park Rangers F.C. in memory of Ray Jones (footballer born 1988)

**Thirty-one** is also:

The number of days in the months January, March, May, July, August, October and December
The code for international direct-dial phone calls to the Netherlands
Thirty-one, a card game
The number of kings defeated by the incoming Israelite settlers in Canaan according to Joshua 12:24: "all the kings, one and thirty" (Wycliffe Bible translation)
A type of game played on a backgammon board
The number of flavors of Baskin-Robbins ice cream; the shops are called *31 Ice Cream* in Japan
ISO 31 is the ISO's standard for quantities and units
In the title of the anime *Ulysses 31*
In the title of Nick Hornby's book *31 Songs*
Turkish slang for male masturbation ("otuzbir")
A women's honorary at The University of Alabama (XXXI)
The number of the French department Haute-Garonne
In music, 31-tone equal temperament is a historically significant tuning system (31 equal temperament), first theorized by Christiaan Huygens and promulgated in the 20th century by Adriaan Fokker
Number of letters in Macedonian alphabet