How to find right child in a pyramid number?

85 Views Asked by At

A pyramid number:

        0
     1     2
   3     4     5
6     7     8    9

So is there any equation like:

right(0) -> 2
right(2) -> 5
right(5) -> 9
right(1) -> 4
right(4) -> 8
right(3) -> 7
1

There are 1 best solutions below

0
On

Hint: Yes, there is such function. If $$\frac{x(x-1)}{2}\leq y<\frac{x(x+1)}{2}$$ then the number is on the $x+1$th row and is the right child $x+2$ bigger. Now find the inverse of the above. Hint: Use a floor function.