The synthetic division table is:
$$ \begin{array}{c|rrrrr}-7&3&18&0&-3&40\\& & -21& 21& -147& \color{black}{1050} \\ \hline &\color{blue}{3}&\color{blue}{-3}&\color{blue}{21}&\color{blue}{-150}&\color{orangered}{1090} \end{array} $$The solution is:
$$ \frac{ 3x^{4}+18x^{3}-3x+40 }{ x+7 } = \color{blue}{3x^{3}-3x^{2}+21x-150} ~+~ \frac{ \color{red}{ 1090 } }{ x+7 } $$Step 1 : Write down the coefficients of the dividend into division table. Put the zero from $ x + 7 = 0 $ ( $ x = \color{blue}{ -7 } $ ) at the left.
$$ \begin{array}{c|rrrrr}\color{blue}{-7}&3&18&0&-3&40\\& & & & & \\ \hline &&&&& \end{array} $$Step 1 : Bring down the leading coefficient to the bottom row.
$$ \begin{array}{c|rrrrr}-7&\color{orangered}{ 3 }&18&0&-3&40\\& & & & & \\ \hline &\color{orangered}{3}&&&& \end{array} $$Step 2 : Multiply by the number on the left, and carry the result into the next column: $ \color{blue}{ -7 } \cdot \color{blue}{ 3 } = \color{blue}{ -21 } $.
$$ \begin{array}{c|rrrrr}\color{blue}{-7}&3&18&0&-3&40\\& & \color{blue}{-21} & & & \\ \hline &\color{blue}{3}&&&& \end{array} $$Step 3 : Add down last column: $ \color{orangered}{ 18 } + \color{orangered}{ \left( -21 \right) } = \color{orangered}{ -3 } $
$$ \begin{array}{c|rrrrr}-7&3&\color{orangered}{ 18 }&0&-3&40\\& & \color{orangered}{-21} & & & \\ \hline &3&\color{orangered}{-3}&&& \end{array} $$Step 4 : Multiply by the number on the left, and carry the result into the next column: $ \color{blue}{ -7 } \cdot \color{blue}{ \left( -3 \right) } = \color{blue}{ 21 } $.
$$ \begin{array}{c|rrrrr}\color{blue}{-7}&3&18&0&-3&40\\& & -21& \color{blue}{21} & & \\ \hline &3&\color{blue}{-3}&&& \end{array} $$Step 5 : Add down last column: $ \color{orangered}{ 0 } + \color{orangered}{ 21 } = \color{orangered}{ 21 } $
$$ \begin{array}{c|rrrrr}-7&3&18&\color{orangered}{ 0 }&-3&40\\& & -21& \color{orangered}{21} & & \\ \hline &3&-3&\color{orangered}{21}&& \end{array} $$Step 6 : Multiply by the number on the left, and carry the result into the next column: $ \color{blue}{ -7 } \cdot \color{blue}{ 21 } = \color{blue}{ -147 } $.
$$ \begin{array}{c|rrrrr}\color{blue}{-7}&3&18&0&-3&40\\& & -21& 21& \color{blue}{-147} & \\ \hline &3&-3&\color{blue}{21}&& \end{array} $$Step 7 : Add down last column: $ \color{orangered}{ -3 } + \color{orangered}{ \left( -147 \right) } = \color{orangered}{ -150 } $
$$ \begin{array}{c|rrrrr}-7&3&18&0&\color{orangered}{ -3 }&40\\& & -21& 21& \color{orangered}{-147} & \\ \hline &3&-3&21&\color{orangered}{-150}& \end{array} $$Step 8 : Multiply by the number on the left, and carry the result into the next column: $ \color{blue}{ -7 } \cdot \color{blue}{ \left( -150 \right) } = \color{blue}{ 1050 } $.
$$ \begin{array}{c|rrrrr}\color{blue}{-7}&3&18&0&-3&40\\& & -21& 21& -147& \color{blue}{1050} \\ \hline &3&-3&21&\color{blue}{-150}& \end{array} $$Step 9 : Add down last column: $ \color{orangered}{ 40 } + \color{orangered}{ 1050 } = \color{orangered}{ 1090 } $
$$ \begin{array}{c|rrrrr}-7&3&18&0&-3&\color{orangered}{ 40 }\\& & -21& 21& -147& \color{orangered}{1050} \\ \hline &\color{blue}{3}&\color{blue}{-3}&\color{blue}{21}&\color{blue}{-150}&\color{orangered}{1090} \end{array} $$Bottom line represents the quotient $ \color{blue}{ 3x^{3}-3x^{2}+21x-150 } $ with a remainder of $ \color{red}{ 1090 } $.