5. Scott stacks golfballs to make a pyramid. The first layer, or base, of the pyramid is a square of golfballs and rests on a flat table. Each golfball, above the first layer, rests in a pocket formed by four golfballs in the layer below (as shown in Figure 1). Each layer, including the first layer, is completely filled. For example, golfballs can be stacked into a pyramid with 3 levels, as shown in Figure 2. The four triangular faces of the pyramid in Figure 2 include a total of exactly 13 different golfballs. Scott makes a pyramid in which the four triangular faces include a total of exactly 145 different golfballs. How many layers does this pyramid have?
5. Solution 1
Suppose that the pyramid has $n$ layers
At each layer, the golfballs that form part of the triangular faces of the pyramid are the golfballs that are part of the perimeter of the layer.
At each layer, the golfballs that are not part of the perimeter are not part of the triangular faces.
The top layer is $1 \times 1$ and this 1 golfball is a part of the triangular faces.
The next layer is $2 \times 2$ and all 4 of these golfballs form part of the triangular faces.
The next layer is $3 \times 3$. There is 1 golfball in the middle of this layer that is not part of the triangular faces.
The next layer is $4 \times 4$. There is a $2 \times 2$ square of golfballs in the middle of this layer, each of which is not part of the triangular faces.
For the layer which is $k \times k$ (with $k>2$ ), there is a $(k-2) \times(k-2)$ square of golfballs in the middle of this layer, each of which is not part of the triangular faces.

If the entire pyramid has $n$ layers, then the total number of golfballs in the pyramid is
$$
1^{2}+2^{2}+3^{2}+4^{2} \cdots+(n-2)^{2}+(n-1)^{2}+n^{2}
$$

From above, the total number of golfballs that do not form a part of the triangular faces is
$$
0+0+1^{2}+2^{2}+\cdots+(n-4)^{2}+(n-3)^{2}+(n-2)^{2}
$$

The total number of golfballs that do form a part of the triangular faces is the difference between these two totals, which equals
$$
\left(1^{2}+2^{2}+3^{2}+4^{2} \cdots+(n-2)^{2}+(n-1)^{2}+n^{2}\right)-\left(0+0+1^{2}+2^{2}+\cdots+(n-4)^{2}+(n-3)^{2}+(n-2)^{2}\right)
$$
which equals $(n-1)^{2}+n^{2}$ since all other terms are added and then subtracted.
We want to determine the value of $n$ for which the pyramid with $n$ layers has 145 golfballs on its triangular faces.
In other words, we want to determine the value of $n$ for which $(n-1)^{2}+n^{2}=145$.
When $n=9$, we obtain $(n-1)^{2}+n^{2}=8^{2}+9^{2}=64+81=145$.
Therefore, the pyramid has 9 layers.
(Note that when $n>2$ and as $n$ increases, each of $(n-1)^{2}$ and $n^{2}$ increases, so $(n-1)^{2}+n^{2}$ increases, and so there is only one $n$ that works.)

Solution 2
Suppose that the pyramid has $n$ layers.
Each of the four triangular faces consists of $n$ rows of golfballs. There is 1 golfball in the top row, 2 golfballs in the next row, and so on, with $n$ golfballs in the bottom row.
Thus, each of the four triangular faces includes $1+2+3+\cdots+n=\frac{1}{2} n(n+1)$ golfballs.
The very top golfball is included in each of the four faces.
Each of the other golfballs along the edges of each triangular face is included in two faces. There are $n-1$ golfballs in each such edge.
To determine the total number of golfballs included in the four triangular faces in terms of $n$, we
- begin with 4 times the number of golfballs in one face,
- subtract 3, to account for the fact that the very top golfball is included 4 times, thus is counted 3 extra times, and
- subtract $4 \times(n-1)$, to account for the fact that each golfball below the top along each of the 4 edges is included twice in the total instead of once.

Thus, the total number of golfballs included in the four triangular faces is
$$
4\left(\frac{1}{2} n(n+1)\right)-3-4(n-1)=2 n(n+1)-3-4 n+4=2 n^{2}+2 n-3-4 n+4=2 n^{2}-2 n+1
$$

For the total number of golfballs included in the four triangular faces to be 145, we have
$$
\begin{aligned}
2 n^{2}-2 n+1 & =145 \\
2 n^{2}-2 n-144 & =0 \\
n^{2}-n-72 & =0 \\
(n-9)(n+8) & =0
\end{aligned}
$$

Therefore, $n=9$ or $n=-8$.
Since $n>0$, then $n=9$, so there are 9 layers.
Solution 3
We count the number of golfballs, by level, that are included in the four triangular faces. The top level consists of $1 \times 1=1$ golfball. This golfball is included in the triangular faces. The next level consists of $2 \times 2=4$ golfballs. All 4 golfballs are included in the triangular faces. The next level consists of $3 \times 3=9$ golfballs. Only the middle golfball of this level is not included in the triangular faces, so 8 golfballs are included in the triangular faces.
In general, for a level that is $k \times k$ with $k>2$, how many of the golfballs are included in the triangular faces?
The golfballs on the perimeter of this square are included in the triangular faces. How many such balls are there?
We start by counting each of the balls on two opposite edges. This gives $k+k=2 k$ golfballs. On the two remaining edges, the balls at each end are already included, leaving $k-2$ golfballs on each of these edges to be counted.
In total, this gives $k+k+(k-2)+(k-2)=4 k-4$ golfballs from this level that are included in the four triangular faces.
We make a table of the level number, the number of golfballs included in the four triangular faces at this level, and the running total of such golfballs. We stop when we get to a total of 145 :
\begin{tabular}{|c|c|c|} 
Level & Exterior golfballs & Running total \\
\hline 1 & 1 & 1 \\
2 & 4 & 5 \\
3 & 8 & 13 \\
4 & 12 & 25 \\
5 & 16 & 41 \\
6 & 20 & 61 \\
7 & 24 & 85 \\
8 & 28 & 113 \\
9 & 32 & 145
\end{tabular}

Therefore, 9 layers are needed to obtain a total of 145 golfballs included in the four triangular faces.
ANSWER: 9 layers