Ta có: \(\left(2x+1\right)^n=\sum_{k=0}^nC_n^k\left(2x\right)^{n-k}\cdot1^k\)
\(=\sum_{k=0}^nC_n^k2^{n-k}\cdot x^{n-k}\).
Theo đề, khi \(n-k=2\) thì \(C_n^k2^{n-k}=40\)
\(\Leftrightarrow C_n^{n-2}2^2=40\Rightarrow C_n^{n-2}=10\)
\(\Rightarrow\dfrac{n!}{\left(n-2\right)!\left[n-\left(n-2\right)\right]!}=10\Leftrightarrow n\left(n-1\right)=20\).
Tìm được \(\left[{}\begin{matrix}n=5\left(N\right)\\n=-4\left(L\right)\end{matrix}\right.\).
Vậy: \(n=5\)