Problem based on sum of binomial coefficients

Let $m$ be the smallest positive integer such that Coefficients of $x^2$ in the expansion

$\displaystyle (1+x)^2+(1+x)^3+.....+(1+x)^{49}+(1+mx)^{50}$ is $\displaystyle (3n+1)\binom{51}{3}$

for some positive integer $n\;,$ Then $n=$

$\bf{My\; Try::}$ Let $$S=\underbrace{(1+x)^2+(1+x)^3+........(1+x)^{49}}_{=\frac{(1+x)^{50}-(1+x)^2}{x}}+(1+mx)^{50}$$

So Coefficient of $x^2$ in $$S=\displaystyle \frac{(1+x)^{50}-(1+x)^2+x(1+mx)^{50}}{x}$$

So So Coefficient of $x^3$ in $$S=\displaystyle(1+x)^{50}-(1+x)^2+x(1+mx)^{50}$$

And which is equal to $$=\binom{50}{3}+m^2\binom{50}{3} = \binom{50}{3}(1+m^2) = (3n+1)\binom{51}{3}$$

So after simplification, We get $$16(1+m^2)=17(3n+1)\Rightarrow 16m^2-51n=1$$

Now How can I calculate $n$ after that, Help required, Thanks

So Coefficient of $x^3$ in $$S=\displaystyle(1+x)^{50}-(1+x)^2+x(1+mx)^{50}$$

And which is equal to $$=\binom{50}{3}+m^2\binom{50}{3} = \binom{50}{3}(1+m^2) = (3n+1)\binom{51}{3}$$

It should be wrong. It should be the following :

$$\binom{50}{3}+m^2\binom{50}{\color{red}{2}} = (3n+1)\binom{51}{3},$$ i.e. $$m=\sqrt{51n+1}$$ Then,

• $\sqrt{51\cdot 1+1}$ is not an integer.

• $\sqrt{51\cdot 2+1}$ is not an integer.

• $\sqrt{51\cdot 3+1}$ is not an integer.

• $\sqrt{51\cdot 4+1}$ is not an integer.

• $\sqrt{51\cdot 5+1}=16$ is an integer.

So, the answer is $\color{red}{n=5}\ (m=16)$.

Assuming what you did is correct:

$$n=\frac{16m^2-1}{51}\implies m=4\,,\;\; n=\frac{16\cdot16-1}{51}=5$$