Let us divide x^3-5x^2+px+6 by x+2 by synthetic division
One Write the coefficients of x in the dividend inside an upside-down division symbol.
color(white)(1)|color(white)(X)1" "color(white)(X)-5color(white)(XX)p" "" "6
color(white)(1)|" "color(white)(X)
" "stackrel("—————————————)
Two As x+2=0 gives x=-2 put -2 at the left.
-2|color(white)(X)1" "color(white)(X)-5color(white)(XX)p" "" "6
color(white)(xx)|" "color(white)(XX)
" "stackrel("—————————————)
Three Drop the first coefficient of the dividend below the division symbol.
-2|color(white)(X)1" "color(white)(X)-5color(white)(XX)p" "" "6
color(white)(xx)|" "color(white)(X)
" "stackrel("—————————————)
color(white)(xx)|color(white)(X)color(red)1
Four Multiply the result by the constant, and put the product in the next column.
-2|color(white)(X)1" "color(white)(X)-5color(white)(XX)p" "" "6
color(white)(xx)|" "color(white)(xxX)-2
" "stackrel("—————————————)
color(white)(xx)|color(white)(X)color(blue)1
Five Add down the column.
-2|color(white)(X)1" "color(white)(X)-5color(white)(XX)p" "" "6
color(white)(xx)|" "color(white)(xXX)-2
" "stackrel("—————————————)
color(white)(xx)|color(white)(X)color(blue)1color(white)(X11)color(red)-7
Six Repeat Steps Four and Five until you can go no farther.
-2|color(white)(X)1" "color(white)(X)-5color(white)(XX)p" "" "color(white)(XX)6
color(white)(xx)|" "color(white)(XXx)-2color(white)(xx)14color(white)(X)-2p-28
" "stackrel("—————------------————————)
color(white)(xx)|color(white)(X)color(blue)1color(white)(XX)color(red)-7color(white)(XX)color(red)(p+14)color(white)()color(red)((-2p-22))
Hence, Quotient is x^2-7x+p+14 and remainder is -2p-22.
We can also work out remainder using remainder theorem, which gives remainder as f(-2) i.e.
f(-2)=(-2)^3-5(-2)^2+p(-2)+6=-8-20-2p+6=-2p-22