What is the tree-planting (uekizan) problem?
The tree-planting problem, known in Japanese elementary arithmetic as "uekizan," asks you to place objects at equal intervals along a span and work out the spacing between them. Its famous twist is the off-by-one relationship between the number of objects and the number of gaps between them. This tool handles the universal math behind every version of the puzzle.
How to use it
Enter the total distance between the two endpoints (for example two buildings), the number of trees you want to plant, and the layout mode. The calculator returns the number of intervals (gaps) and the spacing in meters between each adjacent tree.
The formula explained
Spacing is simply the total length divided by the number of intervals. The number of intervals is what changes with the layout: trees at both ends give \(N - 1\) gaps; one end only or a closed loop give \(N\) gaps; neither end planted gives \(N + 1\) gaps. Choosing the wrong convention is the classic mistake.
$$\text{Spacing} = \frac{\text{Total Distance}}{\text{Trees} - 1}$$
Worked example
Suppose the distance between building A and building B is 100 m and you plant 11 trees, one at each end. Because both ends are planted, the number of gaps is \(11 - 1 = 10\). The spacing is
$$100 \div 10 = 10 \text{ m}$$A common error is dividing 100 by 11, which wrongly gives about 9.09 m.
FAQ
Why do both-ends layouts subtract one? A tree sits at each endpoint, so between \(N\) trees there are only \(N - 1\) spaces.
What about a circular pond? On a closed loop the last tree connects back to the first, so the number of gaps equals the number of trees: \(\text{spacing} = \text{perimeter} / N\).
Can I enter a fraction of a tree? No. The number of trees is rounded to a whole number because you cannot plant a partial tree.