On this page
Put a chess king on the bottom-left corner of a grid and let it move only one square east, one square north, or one square diagonally north-east. How many routes reach the top-right corner? The answer is a Delannoy number, written D(m, n). The numbers are named after the French amateur mathematician Henri-Auguste Delannoy (1833–1915), according to the OEIS entry for the Delannoy array.
What are Delannoy numbers?
D(m, n) is the number of lattice paths from (0, 0) to (m, n) that use only the steps (1, 0), (0, 1) and (1, 1) (OEIS A008288).
Without the diagonal step you have the ordinary grid-path count C(m + n, m). On a 3 × 3 grid, east-and-north paths number C(6, 3) = 20, while the Wikipedia article on Delannoy numbers draws all 63 Delannoy paths. Paths that never rise above the diagonal are counted by a related family, the Schröder numbers.
Cyril Banderier and Sylviane Schwer's historical note Why Delannoy numbers?, in the Journal of Statistical Planning and Inference, surveys Delannoy's work and lists where the numbers turn up: probabilistic game theory, DNA sequence alignment, tiling problems and the analysis of algorithms.
How does the Delannoy recurrence work?
Look at the last step of any path that ends at (m, n). It came from exactly one of three squares: (m − 1, n) by an east step, (m, n − 1) by a north step, or (m − 1, n − 1) by a diagonal step. No path is counted twice, because the last steps differ. So:
D(m, n) = D(m − 1, n) + D(m, n − 1) + D(m − 1, n − 1)
The edges are easy: D(m, 0) = D(0, n) = 1, because along the bottom row or left column there is only one way to go. Both the recurrence and the boundary values are given in OEIS A008288.
What does the Delannoy table look like?
Row n lists D(0, n), D(1, n), and so on up to D(4, n):
n = 0: 1, 1, 1, 1, 1
n = 1: 1, 3, 5, 7, 9
n = 2: 1, 5, 13, 25, 41
n = 3: 1, 7, 25, 63, 129
n = 4: 1, 9, 41, 129, 321
Check one entry: D(4, 4) = D(3, 4) + D(4, 3) + D(3, 3) = 129 + 129 + 63 = 321. The table is symmetric, D(m, n) = D(n, m), because swapping east and north turns one path into another.
The diagonal values 1, 3, 13, 63, 321 are the central Delannoy numbers; OEIS A001850 continues the list with 1683, 8989 and 48639.
Is there a formula for Delannoy numbers?
Yes. The closed form is D(m, n) = Σ C(m, k) C(n, k) 2^k, summed from k = 0 to min(m, n), as listed in OEIS A008288 and on Wikipedia.
Worked for D(3, 3):
k = 0: 1 × 1 × 1 = 1
k = 1: 3 × 3 × 2 = 18
k = 2: 3 × 3 × 4 = 36
k = 3: 1 × 1 × 8 = 8
The total is 63, matching the table.
A second formula is easier to explain. Sort paths by k, the number of diagonal steps. Such a path has k diagonals, m − k east steps and n − k north steps, so m + n − k steps in all, and the number of orders is (m + n − k)! / (k! (m − k)! (n − k)!). For D(3, 3) that gives 20 + 30 + 12 + 1 = 63. Wikipedia derives the closed form this way.
How do you solve a king-path question in an exam?
Read the allowed steps. East and north only: C(m + n, m). East, north and north-east: Delannoy.
For small grids, fill the table with the recurrence, starting from the 1s on the edges.
For larger or symbolic grids, split by the number of diagonal steps and add the cases.
If a square is blocked, write 0 there and keep using the recurrence.
Sanity check: D(1, 1) = 3, and the table must be symmetric.
Try step 4. Count paths from (0, 0) to (2, 2) that avoid (1, 1). With 0 at (1, 1), the recurrence gives 2 at (2, 1), 2 at (1, 2), and 2 + 2 + 0 = 4 at (2, 2). Cross-check: of the 13 paths in total, 3 × 3 = 9 pass through (1, 1), leaving 4.
If a variant like this stalls you, the Fermi Problem Library has a step-by-step solver that explains the reasoning rather than printing an answer, so you can see where your count went wrong.
For more counting practice, work through these JEE Advanced numerical questions on permutations and combinations. Paths with a ceiling lead to Motzkin numbers and their worked n = 4 count and to the ballot problem and the reflection principle.



