# Pleasant Cuboids

A rectangular prism (or cuboid) made up of xyz identical unit cubes (x along its width, y along its length, and z along its height). Some of those cubes are internal, while the rest are external. Such a prism is said to be pleasant if the number of internal and external cubes is the same.

How many pleasant prisms exist?

(Puzzle and solution by Snarky Kesa)

• Didn't Snarky Kesa write those books about the Baudelaire kids? Mar 1 at 14:43
• @msh210 is there a joke there? Those are by Daniel Handler aka Lemony Snicket Mar 2 at 1:18
• The number seems to grow fast with dimensionality. There are only two in the two-dimensional case, versus the number given in answers below for three. Mar 2 at 11:08

We are trying to find positive integer solutions to $$xyz = 2(x-2)(y-2)(z-2)$$.

First I'll establish some bounds.

Lower bound:

$$xyz = 2(x-2)(y-2)(z-2) < 2(x-2)yz\\xyz < 2(x-2)yz\\x < 2x-4\\4 < x$$ This works for any of the dimensions, so all dimensions are at least $$5$$. Note that I am assuming that all the factors involved are positive so that there are actual internal unit cubes in the cuboid. Without that assumption the equation has a solution $$(x,y,z)=(1,1,4)$$, which does not represent a valid solution to the problem.

Upper bound:

Assume wlog that $$x\le y\le z$$. $$xyz = 2(x-2)(y-2)(z-2)\\ \frac{xyz}{(x-2)(y-2)(z-2)} = 2\\ \left( 1+\frac{2}{x-2} \right) \left( 1+\frac{2}{y-2} \right) \left( 1+\frac{2}{z-2} \right) = 2\\ \left( 1+\frac{2}{x-2} \right) ^3 \ge 2\\ \frac{2}{x-2} \ge \sqrt[3]{2}-1\\ \frac{2}{\sqrt[3]{2}-1} \ge x-2\\ 2+\frac{2}{\sqrt[3]{2}-1} \ge x\\ x\le9$$

Now we can check the few cases for $$x$$:

$$xyz = 2(x-2)(y-2)(z-2)$$
Case $$x=5$$:
$$5yz = 6(y-2)(z-2)\\(y-12)(z-12)=120\\(y-12,z-12)=(1,120),(2,60),(3,40),(4,30),(5,24),(6,20),(8,15),(10,12)\\(y,z)=(13,132),(14,72),(15,52),(16,42),(17,36),(18,32),(20,27),(22,24)$$ That's $$8$$ solutions.

Case $$x=6$$:
$$6yz = 8(y-2)(z-2)\\(y-8)(z-8)=48\\(y-8,z-8)=(1,48),(2,24),(3,16),(4,12),(6,8)\\(y,z)=(9,56),(10,32),(11,24),(12,20),(14,16)$$ That's $$5$$ solutions.

Case $$x=7$$: $$7yz = 10(y-2)(z-2)\\(3y-20)(3z-20)=280\\(3y-20,3z-20)=(1,280),(2,140),(4,70),(5,56),(7,40),(8,35),(10,28),(14,20)\\(3y,3z)=(21,300),(22,160),(24,90),(25,76),(27,60),(28,55),(30,48),(34,40)\\(y,z)=(7,100),(8,30),(9,20),(10,16)$$ That's $$4$$ solutions.

Case $$x=8$$: $$8yz = 12(y-2)(z-2)\\(y-6)(z-6)=24\\(y-6,z-6)=(1,24),(2,12),(3,8),(4,6)\\(y,z)=(7,30),(8,18),(9,14),(10,12)$$ Note that the first solution is a permutation of an $$x=7$$ solution.
So that's $$3$$ new solutions.

Case $$x=9$$:
$$9yz = 14(y-2)(z-2)\\9yz = 14(yz-2y-2z+4)\\(5y-28)(5z-28)=504=8*9*7\\(5y-28)(5z-28)= (1,504),(2,252),(3,336),(4,126),(6,168),(7,72),(8,63),(9,112),(12,42),(18,28),(21,24)\\(5y)(5z)= (29,532),(30,280),(31,364),(32,154),(34,196),(35,100),(36,91),(37,140),(40,70),(46,56),(49,52)\\(y,z)=(6,56),(7,20),(8,14)$$ These are all permutations of previously found solutions.
So that's no new solutions.

There are $$8+5+4+3+0=20$$ pleasant prism solutions all together.

I think Weather Vane has identified all the cuboids.

Here is a method to mathematically narrow down your options for $$x,y,z$$ to a finite range

Equation to solve $$2(x-2)(y-2)(z-2) = xyz$$ (essentially what Weather Vane wrote) $$\Rightarrow xyz - 4(xy + yz + xz) +8(x+y+z) - 16 = 0$$ $$\Rightarrow (x-4)(y-4)(z-4) - 8(x+y+z) + 48 = 0$$ Now let $$\tilde{x} = x-4, \tilde{y} = y-4, \tilde{z} = z-4$$. Then $$\tilde{x}\tilde{y}\tilde{z} = 8(\tilde{x} + \tilde{y} + \tilde{z})+48$$ If $$\tilde{x}\tilde{y} = 8$$ then $$\tilde{x}+\tilde{y} = -6$$ which leads to one of $$x$$ or $$y$$ being zero. Otherwise, $$\tilde{z} = \frac{8(\tilde{x} + \tilde{y}) + 48}{\tilde{x}\tilde{y}-8}$$ If the numerator or denominator are non-positive here, that gives us a small number of possibilities to check for $$\tilde{x}$$ and $$\tilde{y}$$. Alternatively, if both numerator and denominator are positive here then the numerator must be at least as big as the denominator to make $$\tilde{z}$$ an integer so we have $$8(\tilde{x} + \tilde{y}) + 48 \geq \tilde{x}\tilde{y} - 8$$ $$\Rightarrow (\tilde{x}-8)(\tilde{y}-8) \leq 120$$ From here, we see that we will only have a finite number of possibilites for $$\tilde{x}$$ and $$\tilde{y}$$ unless one of them is $$8$$. In the case $$\tilde{y}=8$$, for example, we have $$\tilde{z} = \frac{\tilde{x}+14}{\tilde{x}-1}$$ with $$\tilde{x}-1>0$$ which yields integer solutions only for $$\tilde{x} = 2, 4, 6$$ or $$16$$.

I have found

20 cuboids

The number of internal cubes $$i = (x-2)(y-2)(z-2)$$
The number of external cubes $$e = xyz - i$$
Using a small C program with $$3 <= x <= y <= z <= 10000$$

$$x \, \, \, y \, \, z$$
5 13 132
5 14 72
5 15 52
5 16 42
5 17 36
5 18 32
5 20 27
5 22 24
6 9 56
6 10 32
6 11 24
6 12 20
6 14 16
7 7 100
7 8 30
7 9 20
7 10 16
8 8 18
8 9 14
8 10 12

But I don't know how to make a mathematical proof of the limit.

• It would not have been difficult to sbow, without computing any cuboids, that $x\le9,x\le y\le z\le132$ would have been sufficient. Mar 2 at 15:39
• @OscarLanzi but the question asks how many? Without any justification that would also be a hollow answer, and I wrote that I don't know how to arrive at the limits mathematically. Just because you think "it would not have been difficult" and posted an answer, doesn't mean that I would. By listing all the cuboids obtained by computation (which I did find easy), and the expression that I used to compute, the answer is given substance. Your answer is what it is and so is mine. Mar 2 at 15:45

The puzzle technically asked for just the number of cuboids. So in my approach, I emphasize simply counting the solutions rather than listing them.

As discussed elsewhere, the governing equation is

$$2(x-2)(y-2)(z-2)=xyz,$$

and to avoid repeating permutations I shall specify $$x\ge y\ge z$$ (there are cuboids with two equal dimensions). Then writing the equation as

$$\dfrac{x-2}{x}×\dfrac{y-2}{y}×\dfrac{z-2}{z}=\dfrac12$$

implies that $$(z-2)/z\le\sqrt[3]{1/2}<\sqrt[3]{64/125}=4/5$$, thus $$z<10$$. Also positive solutions for $$x$$ and $$y$$ will require $$2(z-2)>z$$ from which $$z>4$$. Hence the candidates for $$z$$ are $$5,6,7,8,9$$.

For $$z=5$$ we have

$$6(x-2)(y-2)=5xy\implies \color{blue}{xy-12x-12y+24=0}.$$

In the blue equation the left side could be factored if the outer terms had the same product as the inner ones. We can adjust the constant term to meet this equality:

$$xy-12x-12y+144=(x-12)(y-12)=120.$$

Then $$x-12$$ and $$y-12$$ will be factors of $$120$$. From the prime factorization $$120=2^3×3×5$$ we can identify $$4×2×2=16$$ total divisors, half of which are below the square root and thus would be values of $$y-12$$ (with $$x\ge y$$). The integer factors are the corresponding values of $$x-12$$. So $$z=5$$ renders eight solutions.

For $$z=6$$ a similar method applies, except we can cut down on the coefficients by removing a factor of $$2$$. We end up with

$$(x-6)(y-6)=48=2^4×3,$$

giving $$5×2=10$$ total divisors half of which again fit each factor. Thus five solutions with $$z=6$$.

For $$z=7$$ we need to be more subtle. Our equation after collecting all like terms is

$$3xy-20x-20y+40=0,$$

but immediately adjusting the constant term to get a factorable expression on the left backfires: we get a fraction! To clear this fraction multiply by $$3$$ and then our adjustment factor is a whole number:

$$9xy-60x-60y+120=0$$

$$(3x-20)(3y-20)=280=2^3×5×7.$$

We need to specify pairs of divisors of $$280$$ that are both one greater than a multiple of $$3$$ (why?). Fortunately, $$280$$ is also one greater than a multiple of $$3$$ and so we can proceed. The numbers $$1,4,7,10$$ are the divisors less than the square root (thus $$3y-20$$) having the required residue, so there are four solutions. One has $$y=z=7$$; the sorting constraint allows this equality.

For $$z=8$$ we use the same method as for $$z=6$$, again removing a common factor of $$2$$. Thereby

$$(y-6)(z-6)=24=2^3×3.$$

We have $$4×2=8$$ total divisors and half are less than the sqare root, but we must reject $$y-6=1$$ due to the constraint $$y\ge z$$. We end with three solutions.

Ou final case is $$z=9$$. This gives

$$5xy-28x-28y+56=0$$

$$25xy-140x-140y+280=0$$

$$(5x-28)(5y-28)=504=2^3×3^2$$

Only the divisors $$2,7$$ and $$12$$ satisfy the requirement that $$5y-28\le\sqrt{504}$$ give a whole number for $$y\le x$$, and $$5y-28=12$$ is too small to satisfy $$y\ge z=9$$. Thus no more soluions.

$$8+5+4+3+0=\boldsymbol{20}$$ cuboids.