0
$\begingroup$

I have a set of numbers:

$\begin{array}{r(22)}x \in \{ 1,& 2,& 3,& 4,& 5,& 6,& 7,& 8,& 9,& 10,& 11,& 12,& 13,& 14,& 15,& 16,& 17,& 18,& 19,& 20,& 21,& 22, \dotsc \} \\ p \in \{ 1,& 2,& 2,& 3,& 3,& 3,& 4,& 4,& 4,& 4,& 5,& 5,& 5,& 5,& 5,& 6,& 6,& 6,& 6,& 6,& 6,& 7, \dotsc \}\end{array}$

The first $x$ matches with the first $p$ and so on...

I am trying to find an equation that will give me the $p$ value given $x$, i have tried $p = \lceil (x-1)^{0.5} \rceil + 1$. It works for the first few values then stops...

Thanks

$\endgroup$
1

2 Answers 2

1
$\begingroup$

Look at it backwards. The highest value of $x$ for a given $p$ is: $$x_h = 1 + 2 +\ldots+ (p-1) + p$$

The sum of the first $p$ natural numbers is: $$\sum_{k=1}^p k = \frac 12 p(p+1) $$

Hence we have a quadratic. $$0 = p^2+p-2x_h \implies p = \frac{-1\pm\sqrt{1+8x_h}}{2}$$

Since $p>0, \forall x>0$ we discard the negative solutions: $$p= \frac{\sqrt{1+8x_h}-1}{2}$$

Since that is for the highest value of $x$ that gives integer $p$, we need to raise the result of lower values to the ceiling.

$$p=\left\lceil \frac{\sqrt{1+8x}-1}2 \right\rceil$$

$\endgroup$
0
$\begingroup$

$$\left\lceil\frac{-1+\sqrt{8x+1}}{2}\right\rceil$$

$\endgroup$
2
  • $\begingroup$ Please explain the rabbit you took out of the hat. $\endgroup$
    – vonbrand
    Apr 3, 2014 at 2:25
  • $\begingroup$ It's just been done in Graham's answer - his method is the same that I used. $\endgroup$
    – David
    Apr 3, 2014 at 2:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .