a) \(5\left(x+4\right)-2x\left(4+x\right)\)
\(=\left(x+4\right)\left(5-2x\right)\)
b) \(\left(x-2017\right)x-5\left(2017-x\right)\)
\(=\left(x-2017\right)x+5\left(x-2017\right)\)
\(=\left(x-2017\right)\left(x+5\right)\)
c) \(\left(x+1\right)^2-\left(x+1\right)\)
\(=\left(x+1\right)\left(x+1-1\right)\)
= \(x\left(x+1\right)\)
d) \(9x^2\left(y-1\right)-18x\left(1-y\right)\)
\(=9x^2\left(y-1\right)+18x\left(y-1\right)\)
\(=\left(y-1\right)\left(9x^2+18x\right)\)
\(=9x\left(y-1\right)\left(x+2\right)\)
e) \(100x^2y-25xy^2-5xy\)
\(=5xy\left(20x-5y-1\right)\)
f) \(\left(n+1\right)n-\left(n+1\right)3\)
\(=\left(n+1\right)\left(n-3\right)\)