Write a C++ code to read x and add the terms of this series: 𝒙+2x^2+3x^3+…+M𝒙^M.