Solving a tough equation involving integer functions I am stuck on solving the equation, given $k\lt\frac{n}{2},\ n,k\ge3$:
$$ m=\lceil 2k-\frac{2}{n}\displaystyle\left(\lfloor\frac{n-\lfloor\frac{n}{k+1}\rfloor}{2}\rfloor\right)(k+1)\rceil$$.
I think the value of $m$ would be $k$. But, the detailed solution is beyond my reach. What inequalities and analysis should we use to reach the solution? Also, what if I modify the equation to:
$$m=\lceil 2\frac{nk}{n-1}-\frac{2}{n-1}\displaystyle\left(\lfloor\frac{n-\lfloor\frac{n}{k+1}\rfloor}{2}\rfloor\right)(k+1)\rceil$$
Will the value of $m=k+1$ at any value of $n,k$? Any hints Thanks beforehand.
 A: We calculate the first expression for integer values $k\geq 0, n\geq 1$.

Let $a,b$ be non-negative integer with
\begin{align*}
  n=a(k+1)+b\qquad\quad a,b\geq 0,\ \  0\leq b<k+1\tag{1}
  \end{align*}
we obtain
\begin{align*}
 \color{blue}{ a(n,k)}
  &\color{blue}{=\left\lceil 2k-\frac{2}{n}\left(\left\lfloor\frac{n-\left\lfloor\frac{n}{k+1}\right\rfloor}{2}\right\rfloor\right)(k+1)\right\rceil}\\
 &=\left\lceil2k-\frac{2}{n}\left(\left\lfloor\frac{n-a}{2}\right\rfloor\right)(k+1)\right\rceil\tag{2}\\
  \end{align*}

Here we use (1) to get $\left\lfloor\frac{n}{k+1}\right\rfloor=\left\lfloor\frac{a(k+1)+b}{k+1}\right\rfloor=a+\left\lfloor\frac{b}{k+1}\right\rfloor=a$ noting that $0\leq b<k+1$.
In (2) we consider two cases: $n-a$ even or odd.

Case 1: $n-a$ even
We obtain from (2)
\begin{align*}
\color{blue}{a(n,k)}
&=\left\lceil2k-\frac{2}{n}\left(\frac{n-a}{2}\right)(k+1)\right\rceil\\
&=\left\lceil2k-\left(\frac{n-a}{n}\right)(k+1)\right\rceil\\
&=\left\lceil2k-\left(1-\frac{a}{n}\right)(k+1)\right\rceil\\
&=\left\lceil k-1+\frac{a(k+1)}{n}\right\rceil\\
&=\left\lceil k-1+\frac{n-b}{n}\right\rceil\tag{3}\\
&=\left\lceil k-\frac{b}{n}\right\rceil\\
&\color{blue}{=}\begin{cases}
\color{blue}{k}&\color{blue}{\qquad n>k}\\
\color{blue}{k-1}&\color{blue}{\qquad n\leq k}\tag{4}
\end{cases}
\end{align*}

Comment:

*

*In (3) we use again the representation (1).


*In (4) we observe from (1) that $n=b$ if $n\leq k$ so that $\left\lceil k-\frac{b}{n}\right\rceil=\left\lceil k-1\right\rceil=k-1$.

Case 2: $n-a$ odd
We obtain from (2)
\begin{align*}
\color{blue}{a(n,k)}
&=\left\lceil2k-\frac{2}{n}\left(\frac{n-a-1}{2}\right)(k+1)\right\rceil\\
&=\left\lceil2k-\left(\frac{n-a-1}{n}\right)(k+1)\right\rceil\\
&=\left\lceil2k-\left(1-\frac{a+1}{n}\right)(k+1)\right\rceil\\
&=\left\lceil k-1+\frac{a(k+1)}{n}+\frac{k+1}{n}\right\rceil\\
&=\left\lceil k-\frac{b}{n}+\frac{k+1}{n}\right\rceil\\
&=k+\left\lceil \frac{k+1-b}{n}\right\rceil\\
&\,\,\color{blue}{=k+1}\\
\end{align*}

The last line follows since from (1) we have $b<k+1$.
A: (not a real answer, but formatting doesn't allow as a comment)
I made the following Python code:
import math

def calculate(n,k):
    aux = math.floor((n- math.floor(n/(k+1)))/2)
    return math.floor(2*k - 2/n * aux * (k+1)) +1 


for n in range(3,25):
    for k in range(3, n/2):
        print "n/k/m = ", n , "/", k ,",", calculate(n,k) -2 * k - 1

And it definitely looks like $m = 2k+1$ in the first case.
