Search topics and sections

Recreational mathematics is mathematics done for fun. It covers puzzles, games, number curiosities, and surprising shapes.[1] Examples include magic squares (grids of numbers whose rows, columns, and diagonals all add to the same sum), river-crossing riddles, the Tower of Hanoi, and the Rubik's Cube.

Its problems run from simple amusements to hard questions, and some have never been solved.[1] A few puzzles even grew into whole fields of research. A puzzle about walking over the bridges of Königsberg started graph theory, and a question about splitting a gambler's stakes helped lay the foundation of probability theory.[2][3]

What it covers

Recreational mathematics is a broad family of problems, not one method. Its puzzles can draw on many fields:[1]

  • arithmetic and algebra
  • geometry
  • number theory
  • graph theory
  • topology, the study of properties that stay the same when a shape is stretched or bent
  • combinatorics, the study of arrangements
  • logic
  • probability

Britannica's survey notes that it is often hard to tell where a pastime ends and serious mathematics begins.[1]

Britannica sorts the material into four rough groups, while noting that no way of sorting it follows a fixed rule:[1]

  • Number recreations: number patterns, puzzles about digits, and curious numbers such as the happy numbers or narcissistic numbers.
  • Geometric and topological recreations: cutting shapes into pieces, mazes, map colouring, folded paper toys, and impossible figures.
  • Hands-on puzzles and games: sliding puzzles, the Tower of Hanoi, polyominoes, and two-player games played with counters.
  • Logic problems: logic puzzles, such as working out who tells the truth and who lies, and logical paradoxes.

Classic examples

A few famous puzzles show the flavour of the field.

Magic squares

A magic square is a grid of numbers in which every row, every column, and both main diagonals add up to the same total, called the magic constant. A standard magic square of side nn uses each whole number from 1 to n2n^2 once. The 3 by 3 square uses 1 to 9, and its lines each add to 15.[4]

A 3 by 3 magic square 2 7 6 9 5 1 4 3 8 15 15 15 15 15 15 15 15
A 3 by 3 magic square that uses the numbers 1 to 9. Each row, each column, and both main diagonals add up to 15, and the centre cell holds 5.

River-crossing puzzles

In a river-crossing puzzle, travellers must get across a river under rules about who may be left together.[5]

The best-known version reads: a farmer must ferry a wolf, a goat, and a cabbage across a river in a boat that holds only the farmer and one item, and nothing may be left alone where it would be eaten.[5]

The earliest known puzzles of this type appear in a Latin collection from around the year 800 (see History).[5]

The Tower of Hanoi

The Tower of Hanoi has three pegs and a stack of disks of different sizes, starting on one peg with the largest at the bottom. The goal is to move the whole stack to another peg, one disk at a time, never putting a disk on a smaller one. A tower of 8 disks needs 255 moves.[6]

Kaprekar's routine

Kaprekar's routine is a process on four-digit numbers that D. R. Kaprekar of India created in 1949.[7] It works like this:

  1. Pick a four-digit number whose digits are not all the same.
  2. Arrange its digits from largest to smallest, and from smallest to largest, keeping any zeros so each number has four digits.
  3. Subtract the smaller number from the larger.
  4. Repeat with the result.

Every such starting number reaches 6174 within seven steps, and 6174 then repeats forever.[7] For example, 9871 − 1789 = 8082, then 8820 − 0288 = 8532, then 8532 − 2358 = 6174, and 7641 − 1467 = 6174 again.

Kaprekar's routine starting from 2005 2005 5175 5994 5355 1998 8082 8532 6174 5200 − 0025 7551 − 1557 9954 − 4599 5553 − 3555 9981 − 1899 8820 − 0288 8532 − 2358 step 1 step 2 step 3 step 4 step 5 step 6 step 7 7641 − 1467 = 6174 7 steps, the most any start needs
Kaprekar's routine applied to 2005. At each step the digits are arranged from largest to smallest and from smallest to largest, and the smaller number is subtracted from the larger. The chain reaches 6174, the number the routine always ends on and then repeats, in 7 steps, the most any four-digit start needs, and stays there because 7641−1467=61747641 - 1467 = 6174.

The Game of Life

The Game of Life, invented by John Horton Conway, is played on an endless grid of square cells. Each cell has eight neighbours, four touching its sides and four touching its corners. Each cell is either filled (alive) or empty.[8]

All cells update at once, and each such update of all the cells is called a generation. The rules are:[8]

  • Survival: a live cell with two or three live neighbours stays alive.
  • Death: a live cell with four or more live neighbours dies of overcrowding, and one with one or no live neighbours dies of isolation.
  • Birth: an empty cell with exactly three live neighbours comes to life.

These simple rules produce patterns that stay still, blink, or travel across the grid. The five-cell "glider" moves one cell diagonally every four generations.[8] A pattern that repeats itself over time, such as the blinker below, is called an oscillator.

Blinker oscillator in Conway's Game of Life 1 2 1 3 3 Generation 1 Generation 2 dies (1 neighbour) survives (2) born (3)
The blinker, an oscillator (a pattern that repeats over time) in Conway's Game of Life. In Generation 1 the two end cells have 1 live neighbour and die, the centre cell has 2 and survives, and the empty cells above and below the centre have 3 and are born, so the row of three becomes a column and the pattern flips back and forth every generation.

Shape curiosities

Geometric recreations often show shapes that behave in unexpected ways. A flexagon is a polygon folded from a strip of paper that shows a different face when it is flexed.[2] One of the simplest is the trihexaflexagon, a flat hexagon with three faces, folded from a strip marked into 10 equal-sided triangles.[2][9]

Flexagons were first discussed in 1939.[2] The first one was folded that year by Arthur H. Stone, a graduate student at Princeton University.[9]

The Koch snowflake starts from a triangle and is built in steps:[10]

  1. Split each side into thirds.
  2. Replace the middle third with two sides of a smaller triangle pointing outward.
  3. Repeat forever on every new side.

Each stage makes the perimeter (the total length around the shape) 4/3 as long, so the perimeter grows without limit. The enclosed area still never exceeds 8/5 of the starting triangle's area.[10]

First three stages of the Koch snowflake Stage 0 Stage 1 Stage 2 perimeter 1 perimeter 4/3 perimeter 16/9 Perimeter grows without limit; area stays below 8/5 of the first triangle
The first three stages of the Koch snowflake. Each stage replaces the middle third of every side with an outward triangular bump, so the side count goes from 3 to 12 to 48 and the perimeter grows by a factor of 4/34/3 at each step. The area always stays below 8/58/5 of the starting triangle.

History

Puzzles for pleasure are very old, and many have been retold in new forms for centuries.[1] The timeline below marks some milestones from the sections that follow.

Timeline of recreational mathematics, c. 800 to 2010 c. 800Propositiones(Charlemagne) 1654Pascal, Fermatprobability 1892Rouse BallRecreations 1993First Gathering4 Gardner 1612BachetProblèmes plaisans 1735-36EulerKönigsberg bridges 1970Game of Life 1202Fibonacci 1694OzanamRécréations Dec 1956GardnerGames column 2010Rubik's CubeGod's number 20 1624LeurechonRécréations 1882-94LucasRécréations 1976Four colourtheorem Books and columns Discoveries Gathering
Milestones in recreational mathematics from the Propositiones ad Acuendos Juvenes (c. 800) to the proof in 2010 that God's number for the Rubik's Cube is 20, meaning every position can be solved in 20 moves or fewer. The events are not drawn to scale, and the gap between c. 800 and 1202 is marked with a break.

Medieval puzzle collections

The Propositiones ad Acuendos Juvenes ("Problems to Sharpen the Young") is the oldest collection of mathematical problems in Latin.[11] Its main facts:

  • Date: it comes from the court of Charlemagne, around 800.[11]
  • Author: manuscripts credit it to the scholar Alcuin of York (735 to 804), but there is no direct evidence that he wrote it or put it together.[5][12]
  • Contents: it has 53 or 56 problems, depending on the copy.[5]
  • Sources: many problem types were already known from older Chinese, Indian, Greek, and Roman sources, but river-crossing problems are not yet known from any earlier source.[5]

Interest in such problems grew through the Middle Ages, helped by printing and by writers of arithmetic textbooks. Contributors named by Britannica include Fibonacci (1202), Robert Recorde (1542), and Girolamo Cardano (1545).[1]

One problem from this era asks how many grains of wheat fill a chessboard if the first square holds 1 grain and each later square holds twice as many as the one before.[1]

Printed books of recreations

In the 17th century, whole books were given over to recreational problems.[1]

Year Author Book Note
1612 Claude-Gaspar Bachet de Méziriac Problèmes plaisans et délectables Mostly arithmetic puzzles; a model for later collections
1624 Jean Leurechon (as "van Etten") Récréations mathématiques At least 30 editions before 1700
1694 Jacques Ozanam Récréations mathématiques et physiques A model for books over the next 200 years
1882 to 1894 Édouard Lucas Récréations mathématiques, 4 volumes Became a classic

In the late 19th century, Lewis Carroll (C. L. Dodgson) wrote mathematical recreations including The Game of Logic, Pillow Problems, and A Tangled Tale.[1]

Puzzle columns and surveys

Around 1900, puzzle makers reached a mass audience through newspapers and magazines. Sam Loyd sold a weekly puzzle column to a national syndicate (a company that supplies material to many newspapers at once). Henry Dudeney wrote for the Strand Magazine and published popular puzzle collections.[1]

Academic surveys appeared in the same period.[1]

Author Work Year Details
W. W. Rouse Ball Mathematical Recreations and Essays 1892 First edition; revised by H. S. M. Coxeter in 1938 and still a standard reference
Wilhelm Ahrens Mathematische Unterhaltungen und Spiele 1910 Two volumes with a large list of sources

Martin Gardner

Martin Gardner wrote the "Mathematical Games" column in Scientific American. Its main facts:

  • Run: it began in December 1956 with an article on flexagons and ran until 1981.[13][14]
  • Influence: it had a huge impact on the way people view mathematics, although Gardner had little mathematical training.[14]
  • Books: the columns were later reprinted in fifteen books.[15]
  • The Game of Life: the October 1970 column first presented Conway's Game of Life to the public.[8]

A shift toward harder topics

Around the middle of the 20th century, the field's interest shifted from number tricks and simple geometric puzzles toward harder topics. These included graphs, group theory (the mathematics of symmetry), topology, combinatorics, and paradoxes of the infinite (questions about infinity that seem to lead to contradictions).[1]

The field today

Recreational mathematics now has its own meetings and journals. The Gathering 4 Gardner is an invitation-only conference in Gardner's honour; the first was held in Atlanta in January 1993, and since 1996 they have usually been held every two years.[16] The Journal of Recreational Mathematics was published from 1968 to 2014.[17]

Why the puzzles work

This section gives the reasoning behind the magic sum and the Tower of Hanoi count from "Classic examples". It also adds new examples: parity (whether a count is odd or even) in the Fifteen Puzzle, the winning rule for Nim, and a computer search for the Rubik's Cube.

The magic sum

The magic constant of a standard magic square follows from adding all its numbers. The numbers 1 to n2n^2 add to n2(n2+1)/2n^2(n^2+1)/2, and this total splits equally among the nn rows, so[18]

M(n)=n(n2+1)2M(n) = \frac{n(n^2+1)}{2}

Here nn is the number of cells on a side and M(n)M(n) is the sum of each row, column, and main diagonal. For n=3n = 3 this gives 15, and for n=4n = 4 it gives 34.[18]

There are exactly 880 standard 4 by 4 magic squares when rotations and reflections are not counted separately, or 7,040 in all.[19]

Counting Tower of Hanoi moves

The Tower of Hanoi count comes from a simple plan for moving nn disks:[20]

  1. Move the top n−1n-1 disks to the spare peg.
  2. Move the largest disk to the goal peg.
  3. Move the n−1n-1 disks back on top of it.

This plan is recursive, because it solves the puzzle by solving the same smaller puzzle twice.[20]

Recursive solution of the Tower of Hanoin − 1 disksStartStep 1Step 2Step 3n − 1 disks to Bm(n − 1) movesLargest disk to C1 moven − 1 disks to Cm(n − 1) movesABCABCABCABCstartsparegoalstartsparegoalstartsparegoalstartsparegoalm(n) = 2 m(n − 1) + 1
The recursive strategy for the Tower of Hanoi solves the same smaller puzzle twice: it moves the top n−1n-1 disks to the spare peg, then the largest disk to the goal peg, then the n−1n-1 disks onto it. This gives m(n)=2 m(n−1)+1m(n) = 2\,m(n-1) + 1 moves.

If m(n)m(n) is the number of moves this plan uses for nn disks, then m(1)=1m(1) = 1 and

m(n)=2 m(n−1)+1.m(n) = 2\,m(n-1) + 1 .

Solving this gives m(n)=2n−1m(n) = 2^n - 1, and no shorter solution exists.[6] A tower of 64 disks would need 264−12^{64} - 1 = 18,446,744,073,709,551,615 moves. That is the same number as the grains of wheat in the medieval chessboard problem.[6]

The puzzle is widely believed to have been invented by Lucas in 1883, though his role in its invention has been disputed.[6]

Parity and the Fifteen Puzzle

Parity can show that a puzzle has no solution, and the Fifteen Puzzle is a classic example.[6]

The puzzle is a tray of 15 numbered sliding squares and one blank space. The goal is to slide the squares into numerical order with the blank in the lower-right corner.[6]

Sam Loyd claimed to have invented the puzzle around 1878, but scholars have documented earlier inventors.[6]

The pieces, including the blank, can be arranged in more than 20,000,000,000,000 ways. In 1879, two American mathematicians proved that only half of these can be solved.[6] The test uses inversions:

  • Read the numbers row by row, left to right, with the blank in the lower-right corner.
  • Each time a number comes before a smaller number, count one inversion.
  • If the total number of inversions is even, the puzzle can be solved. If it is odd, it cannot.[6]

For example, in the sequence 9, 5, 3, 4, the 9 comes before three smaller numbers and the 5 before two, giving five inversions.[6]

Winning at Nim

Nim is a two-player game with a complete winning strategy, which Charles Bouton published in 1901.[21] Players take turns removing one or more counters from a single pile, and whoever takes the last counter wins.[21]

Bouton's rule uses binary numbers:[21]

  1. Write each pile size in binary.
  2. Line up the digits in columns.
  3. Add each column.

If every column sum is even, the position is a "safe combination".[21]

Pile Size Binary
1 9 1001
2 5 0101
3 12 1100
Column sums 2, 2, 0, 2

All column sums here are even, so 9, 5, 12 is a safe combination.[21] Bouton proved that a player who leaves a safe combination can always leave another one on their next turn, while the opponent never can, so that player takes the last counter. The first player wins if the starting position is not safe, and loses against perfect play if it is.[21]

Searching by computer: the Rubik's Cube

Some puzzle questions are settled by huge computer searches. The Rubik's Cube has 43,252,003,274,489,856,000 positions.[22] The fewest moves that solve the hardest position is called God's number, and the method that always finds the shortest solution is called God's algorithm.[22]

Counting any twist of any face as one move, a position needing 20 moves was found in 1995. In July 2010, Tomas Rokicki, Herbert Kociemba, Morley Davidson, and John Dethridge proved that 20 moves are always enough. They used donated Google computer time equal to about 35 years on one processor.[22]

From play to research

Several puzzles have turned into serious branches of mathematics.

Königsberg and graph theory

The city of Königsberg (now Kaliningrad) lay on both banks of the Pregel River and on an island in it, joined by seven bridges. People asked whether someone could take a walk that crosses each bridge exactly once.[2] Leonhard Euler presented a paper on the problem to the St. Petersburg Academy in 1735 and wrote up his solution the following year.[23]

The seven bridges of Königsberg as a graph Königsberg B C A D a b c d e f g As a graph A: 5 B: 3 C: 3 D: 3 Four odd points, so no walk crosses every bridge once
Königsberg's four land areas and seven bridges, drawn as a graph with one dot per land area and one edge per bridge. Every dot meets an odd number of edges (AA: 5, BB, CC, DD: 3), so no walk crosses each bridge exactly once.

Euler's argument counts bridges. Five bridges lead to the island and three lead to each of the other three land areas.[24] A walk over all seven bridges passes through eight places in order. The island must appear three times in that list and each other area twice, which needs nine places, so no such walk exists.[24]

Euler's reasoning gives general rules for any connected network of points and lines. Call a point odd if an odd number of lines meet there.[2]

  • The number of odd points is always even.
  • With no odd points, a single route can trace every line once, starting and ending at the same point.
  • With exactly two odd points, a single route can trace every line once, starting at one odd point and ending at the other.
  • With more than two odd points, no single route can do it.

Euler proved that these conditions are needed, meaning a route can exist only when they hold. He discussed, but did not prove, that they are also enough for a route to exist. A valid proof that they are enough was not published until 1873, by Carl Hierholzer.[23]

Britannica dates the start of modern graph theory to this work, and such routes are now called Eulerian paths.[2] (See also Seven Bridges of Königsberg.)

Gambling and probability

The problem of points asks how to split the prize fairly when a game of chance stops before anyone has won. Luca Pacioli posed it in 1494.[3] In 1654 the gambler Antoine Gombaud brought it to Blaise Pascal, and Pascal's letters with Pierre de Fermat that year laid the foundation of modern probability theory.[3]

Both men looked at how the game could have continued, not at how it had gone so far.[3]

Person Approach
Fermat Listed every possible outcome of the remaining rounds and counted those that each player would win
Pascal Worked backward from the end of the game, one round at a time

Combinatorial games

Conway produced results in combinatorial game theory, the study of two-player games with no chance and no hidden information. With Elwyn Berlekamp and Richard K. Guy, he wrote Winning Ways for Your Mathematical Plays (1982).[25]

Cellular automata

The Game of Life is an example of a cellular automaton, a grid of cells that update by fixed local rules. Conway built it while trying to simplify John von Neumann's idea of a machine that can build copies of itself.[25]

Polyominoes

The word polyomino was coined in 1953 as a joke on "domino".[6] A polyomino is a shape made of one or more equal squares joined along full edges into a single connected piece, so a lone square (a monomino) also counts.[26]

There are exactly 12 pentominoes (five squares) and 35 hexominoes (six squares), but no general formula is known for the number of polyominoes of each size.[6]

Map colouring and computer proofs

The four colour problem asked whether any flat map can be coloured with four colours so that neighbouring regions always differ. It was framed in 1852 and resisted proof until 1976, when mathematicians at the University of Illinois announced that four colours are enough.[2] Their proof used more than 1,000 hours of computer calculation and was the first major proof to rely heavily on a computer.[2]

A similar story belongs to squaring the square, the task of cutting a square into smaller squares that are all different sizes. It was thought impossible as early as 1907, and the first solution was reported in 1939.[10]

The field includes many named numbers, puzzles, people, and publications. Pages on this site include:

References

  1. Number game: Introduction and History, William L. Schaaf, Encyclopaedia Britannica, 2023.
  2. Number game: Graphs and networks, map colouring, flexagons, William L. Schaaf, Encyclopaedia Britannica, 2023.
  3. July 1654: Pascal's Letters to Fermat on the "Problem of Points", APS News, American Physical Society, 2009.
  4. Magic square, Encyclopaedia Britannica, accessed 2026.
  5. Problems to Sharpen the Young, John Carlos Baez, Azimuth, 2025.
  6. Number game: Manipulative recreations, William L. Schaaf, Encyclopaedia Britannica, 2023.
  7. Mysterious number 6174, Yutaka Nishiyama, Plus Magazine, University of Cambridge, 2006.
  8. Mathematical Games: The fantastic combinations of John Conway's new solitaire game "life", Martin Gardner, Scientific American, 1970.
  9. Mathematical Games: Flexagons, Martin Gardner, Scientific American, 1956.
  10. Number game: Geometric and topological recreations, William L. Schaaf, Encyclopaedia Britannica, 2023.
  11. The History of some of Alcuin's Propositiones, David Singmaster, in Charlemagne and his Heritage, vol. 2, Brepols, 1998.
  12. Review of Alcuin's Recreational Mathematics: River Crossings and other Timeless Puzzles, Tricia Muldoon Brown, Mathematical Association of America, 2026.
  13. Hexaflexagons, Martin Gardner, The College Mathematics Journal, 2012.
  14. Flexagon but Not Forgotten: Celebrating Martin Gardner's Birthday, Scientific American, 2012.
  15. Martin Gardner (1914 to 2010) biography, MacTutor History of Mathematics, University of St Andrews, accessed 2026.
  16. The Gathering, Gathering 4 Gardner, accessed 2026.
  17. Journal of recreational mathematics (catalogue record), Stanford Libraries SearchWorks, accessed 2026.
  18. Magic Constant, Eric W. Weisstein, Wolfram MathWorld, accessed 2026.
  19. Squaring the magic squares of order 4, Stefano Barbero, Umberto Cerruti, and Nadir Murru, arXiv, 2013.
  20. The Towers of Hanoi, Plus Magazine, University of Cambridge, 2006.
  21. Nim, A Game with a Complete Mathematical Theory, Charles L. Bouton, Annals of Mathematics, 1901.
  22. God's Number is 20, Tomas Rokicki, Herbert Kociemba, Morley Davidson, and John Dethridge, 2010.
  23. An historical note: Euler's Königsberg letters, Horst Sachs, Michael Stiebitz, and Robin J. Wilson, Journal of Graph Theory, 1988.
  24. Solution of a problem in the geometry of position (English translation), Leonhard Euler, translated by Michael Behrend, 1736.
  25. John Conway (1937 to 2020) biography, J. J. O'Connor and E. F. Robertson, MacTutor History of Mathematics, University of St Andrews, 2004.
  26. Polyomino, Eric W. Weisstein, Wolfram MathWorld, accessed 2026.

Figure

Subtopics

Alcuin of YorkApocalyptic number (mathematics)Arithmetic billiardsAutomorphic numberBan numberChampionnat International de Jeux Mathématiques et LogiquesClyde E. LoveConway's LUX method for magic squaresCrux MathematicorumDerrick NiedermanDisentanglement puzzleDissection puzzleEureka (University of Cambridge magazine)FactorionFlanders Mathematics OlympiadFlexagonFourier divisionFriedman numberGary AntonickGathering 4 GardnerGentleman's DiaryHappy numberHenry DudeneyInteresting number paradoxJohn Horton ConwayJohn NunnJohn Tipper (mathematician)Jorge Nuno SilvaJournal of Recreational MathematicsJúlio César de Mello e SouzaKaprekar numberKaprekar's routineKeith numberKruskal countLee SallowsLeigh MercerLeo MoserLewis CarrollLogic puzzleLook-and-say sequenceLute of PythagorasMaekawa's theoremMagic circle (mathematics)Magic seriesMagic squareMandelbrot CompetitionManifold (magazine)Maris–McGwire–Sosa pairMartin GardnerMathematical card trickMathematical coincidenceMathematical gameMathematical PieMathematical puzzleMathleteN-dimensional sequential move puzzleNarcissistic numberOrigami Polyhedra DesignPandigital numberPaul ZeitzPerfect digit-to-digit invariantPerfect digital invariantPlaying with InfinityPocket CubePolyhexPolyiamondPolyominoPolystickPrime Suspects: The Anatomy of Integers and PermutationsProblem Solving Through Recreational MathematicsPropositiones ad Acuendos JuvenesRichard K. GuyRichard RusczykRubik's CubeSam LoydStrobogrammatic numberStrong law of small numbersThe Game of LogicThe Lady's and Gentleman's DiaryThe Penguin Dictionary of Curious and Interesting NumbersThe Simple Solution to Rubik's CubeThe Tower of Hanoi – Myths and MathsTim ChartierTo Mock a MockingbirdTournament of the TownsTwo-cube calendarUCT Mathematics CompetitionUlam spiralUnderwood DudleyUndulating numberVampire numberWilhelm AhrensWilliam KolakoskiWorld Maths Day