# Solve : $\frac{n}{2}(n+1)=2014+2k$.

$n,k$ are positive integers and $n>k$, solve the equation : $$\frac{n(n+1)}{2}=2014+2k.$$

the first thing I did is to write the LHS as $(2n+1)^2$ but I face an equation like $ak+b=m^2$, I know it has infinitely many solution, I know how to deal with this kind of equation if the LHS in the latter one is a second degree polynomial (doing some factorization), but I can't do the same in this case, Can you show me to do it ?

• how to solve if we dont know $k$? Commented Apr 12, 2013 at 9:12
• I suppose, this is a part of a question? Commented Apr 12, 2013 at 9:15
• @dato : you do solve it for $n,k$ (Diophantine equation). Commented Apr 12, 2013 at 9:45
• @aziiri : Well it is a Diophantine equation, but due to the $n^2$ it's not a linear one and there is no general way to solve it. Commented Apr 12, 2013 at 9:50
• @Dolma : this was proposed in a maths contest, and the absence of general way doesn't mean that we can't solve it (for instance if the LHS was $k^2$ instead of $2k$ it would be much easier). Commented Apr 12, 2013 at 9:52

We have $4028=n(n+1)-4k$

As we need $n>k, -k>-n$

$n(n+1)-4k>n(n+1)-4n=n^2-3n$

$\implies n^2-3n<4028$

the roots of $n^2-3n-4028=0$ are $\frac{3\pm\sqrt{3^2-4\cdot1\cdot(4028)}}2=\frac{3\pm\sqrt{16221}}2$

$\implies 0<n<\approx 64.98$

As Inceptio has identified $n\ge 63, n=63, 64$

$\dfrac{n(n+1)-4028}{2}=2k \implies n(n+1)-4028=4k \implies 4 |n$ or $n+1$.

$n>k$, for what values do you get positive values for this expression:$n(n+1)-4028$ ?

$n(n+1)-4028 >0 \implies n(n+1)>4028$ . When is this attainable? $\sqrt{4028} \approx63$

We can take $63(64)-4028=4k$ and $65(64)-4028=4k$

Now you have a constrain $n>k$. What happens when $n=67$? $k=132$ , it is not allowed. Therefore, you can conclude only two pairs of solutions: $(n,k)=(63,1)$ and $(64,33)$.

• Yes I know that, what should do next ? casework yielded nothing. Commented Apr 12, 2013 at 9:44
• Edited with a detailed answer.Have a look. Commented Apr 12, 2013 at 10:19
• Yes, you're very right! As long as $n>k$, you can only have those two pairs of solutions, and this is because the function $k\mapsto n(k)-k$ is strictly decreasing so whenever it gets negative (i.e. when you find a $k_0$ such that $n\leq k_0$) then it will never get positive again and so $\forall k\geq k_0 , n\leq k$ Commented Apr 12, 2013 at 11:21
• Right . Also you can just argue with simple number theory. Which is closed under $\mathbb{Z}$ or $\mathbb{N}$. SO, it cuts off many possibilities. Commented Apr 12, 2013 at 11:25

Well you can rewrite the equation as:

$n^2+n-4(1007+k)=0$

You solve this equation the usual way and you get your condition on $k$:

$\Delta=1+16(1007+k)$

Now, $(\Delta=0)\Leftrightarrow(k=-(1007+\frac{1}{16})=k_0)$ and ($\Delta>0)\Leftrightarrow(k>k_0)$

In the first case, your resulting $n$ would be: $n=-\frac{1}{2}$ which is not in $\mathbb{N}$ so not a solution.

In the second case you have two possible solutions:

$\cases{n_1=\frac{-1-\sqrt{\Delta}}{2}=\frac{-1-\sqrt{1+16(1007+k)}}{2} \\ n_2=\frac{-1+\sqrt{\Delta}}{2}=\frac{-1+\sqrt{1+16(1007+k)}}{2}}$

For those to be in $\mathbb{N}$, the numerator needs to be a multiple of $2$ (and an integer of course). Now you just have to find all the $k>k_0$ for which $n_1$ and/or $n_2$ is in $\mathbb{N}$.

• And you can also use the condition that Inceptio suggests: $4|n$ or $4|(n+1)$ ;) Commented Apr 12, 2013 at 9:29
• I can't see how this can be useful, $\Delta$ must be a perfect square which I can't find the specific values of $k$ that verify this (I said it in the bottom of the question). @Inceptio : there are two solutions. Commented Apr 12, 2013 at 9:50
• @aziiri : Inceptio was not asking how many solutions there was for each $k$ but how many there was in total (for all applicable $k$) Commented Apr 12, 2013 at 10:05

If your equation is multiplied by $8$ and $1$ added to both sides you get $$(2n+1)^2=16k+16113.$$ An odd square is $1$ mod 8, and so is $16113$, so things look good. Then as noted by Inceptio only half of these actually work, giving $n=0,3$ mod $8$. So we can start with any such $n$ and just compute $$k=\frac{(2n+1)^2-16113}{16}.$$ (If you use an $n=1,2$ mod 4 what happens is this formula gives a half integer for $k$.)