Is there an easy way to solve $x(x-1)(x-2)=2y$ for positive integers?

125 Views Asked by At

I need to solve $$x(x-1)(x-2) = 2y$$ to find $x$ given $y$. It is known that both $x$ and $y$ are positive integers. Is there an easier way than using cube root formulae?

Edit 1: People have requested context. Here is the actual problem. There is a set $S_1$ containing $x$ distinct elements. Then another set $S_2$ is constructed from all possible triplets of elements in $S_1$, under the following additional conditions:

  1. All elements in each triplet must be distinct
  2. Permutation of the last two elements in the triplet is considered the same element. For example, triplet (A,B,C) is considered identical to the triplet (A,C,B) but distinct from (B,A,C).

I know $y$, the size of the set $S_2$, and I would like to find $x$, the size of the original set. It is not hard to figure out that $x$ and $y$ are related via the equation above. I need a function that solves the above equation for $x$ given a valid $y$. By valid I mean that I will only ever use the values of $y$ that have originally been constructed from some positive integer $x$ using the above equation.

I hope this helps with context requirements

1

There are 1 best solutions below

0
On BEST ANSWER

Comment expanded to answer per request.

For any $x > 2$, we have

$$(x-1)^3 = (x-1)(x^2-2x+1) > x(x-1)(x-2) > (x-2)^3$$ This means for any valid $y$ (i.e one satsifies $2y = x(x-1)(x-2)$ for some $x$),

$$(x-1)^3 > 2y > (x-2)^3 \implies (x-1) > \sqrt[3]{2y} > (x-2)$$ Since $x$ is supposed to be an integer, this leads to $$x = 1 + \left\lceil \sqrt[3]{2y} \right\rceil = 2 + \left\lfloor \sqrt[3]{2y} \right\rfloor$$