Project Euler Problem 251

A triplet of positive integers (a, b, c) is called a Cardano Triplet if it satisfies the condition: For example, (2,1,5)

Project Euler Problem 251

Solution

Answer: 18946051

Let

$$x=\sqrt[3]{a+b\sqrt c}, \qquad y=\sqrt[3]{a-b\sqrt c}.$$

We are given

$$x+y=1.$$

Also,

$$x^3+y^3=(a+b\sqrt c)+(a-b\sqrt c)=2a.$$

Using

$$x^3+y^3=(x+y)^3-3xy(x+y),$$

and $x+y=1$,

$$2a = 1-3xy.$$

So

$$xy=\frac{1-2a}{3}.$$

Since

$$xy=\sqrt[3]{a^2-b^2c},$$

we cube both sides:

$$a^2-b^2c=\left(\frac{1-2a}{3}\right)^3.$$

For the right-hand side to be integral, $2a-1$ must be divisible by $3$. Write

$$a=3k+2 \qquad (k\ge0).$$

Then

$$\frac{1-2a}{3}=-(2k+1),$$

hence

$$b^2c = a^2+(2k+1)^3.$$

Substituting $a=3k+2$,

$$b^2c = (3k+2)^2+(2k+1)^3.$$

A crucial factorization appears:

$$(3k+2)^2+(2k+1)^3 = (k+1)^2(8k+5).$$

Thus every Cardano triplet is parameterized by

$$a=3k+2,$$

and

$$b^2c=(k+1)^2(8k+5).$$

For each $k$, every valid $b$ is such that $b^2$ divides $(k+1)^2(8k+5)$, with

$$c=\frac{(k+1)^2(8k+5)}{b^2},$$

subject to

$$a+b+c\le 110{,}000{,}000.$$

A carefully optimized divisor enumeration reproduces the check value $149$ for $a+b+c\le1000$, matching the problem statement, and then evaluates the full limit.

Answer: 18946051