11
$\begingroup$

I want to determine the closest Triangular number a particular natural number is. For example, the first 10 triangular numbers are $1,3,6,10,15,21,28,36,45,55$ and thus, the number $57$ can be written as $$57=T_{10}+2$$ The number $54$ can be written as $$54=T_{9}+9\neq T_{10}-1$$ The second part highlights that I am looking for Triangular numbers larger than a particular positive, and not necessarily "closer" in terms of distance from Triangular numbers.

My approach would be this; given the $n$-th Triangular number has the formula $$T_n=\frac{n(n+1)}{2}=\binom{n+1}{2}$$ If I'm looking for a particular breakdown and close Triangular number, my number, say, $M$ will be of the form $$M=T_k+r$$ where $0\le r\le k$, and thus $$2(M-r)=k^2+k$$ And thus $$k=\frac{-1\pm\sqrt{1+8(M-r)}}{2}$$ I'm lost here in trying to solve, given that $r$ varies. I know that $r$ is less than or equal to $k$ but for sufficiently large $M$, how would I go about finishing solving?

$\endgroup$

1 Answer 1

14
$\begingroup$

$\binom{k}{2}\leq n$ is equivalent to $(2k-1)^2 \leq 8n+1$, hence the largest triangular number $\leq n$ is given by $\binom{k}{2}$ with: $$ k = \left\lfloor \frac{1+\sqrt{8n+1}}{2}\right\rfloor.$$

$\endgroup$
7
  • 1
    $\begingroup$ That was easier than I anticipated...should have known that you could floor out the $r$. Thanks! $\endgroup$
    – Lalaloopsy
    Commented Sep 1, 2015 at 22:07
  • 1
    $\begingroup$ @Lalaloopsy: it is exactly the same, you are just replacing my $k$ with your $k+1$. $\endgroup$ Commented Sep 2, 2015 at 0:05
  • 1
    $\begingroup$ So, just a semantical argument and either way works....right? $\endgroup$
    – Lalaloopsy
    Commented Sep 2, 2015 at 0:10
  • 1
    $\begingroup$ I think @Lalaloopsy 's inequality is correct and the final result is k=$\lceil\frac{-1+\sqrt{8n+1}}{2}\rceil$. $\endgroup$ Commented Mar 31, 2020 at 16:26
  • 2
    $\begingroup$ @user2582713 yes, with floor instead of ceiling, though $\endgroup$
    – Cireo
    Commented Jul 2, 2020 at 23:27

You must log in to answer this question.

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