Lời giải:
\(B=x^2y+xy^2+x^2z+xz^2+y^2z+yz^2+2xyz\)
\(=(x^2y+xy^2+xyz)+(x^2z+xz^2+xyz)+(y^2z+yz^2)\)
\(=xy(x+y+z)+xz(x+z+y)+yz(y+z)\)
\(=(x+y+z)(xy+xz)+yz(y+z)\)
\(=x(x+y+z)(y+z)+yz(y+z)\)
\(=(y+z)(x^2+xy+xz+yz)\)
\(=(y+z)[x(x+y)+z(x+y)]\)
\(=(x+y)(x+y)(x+z)\)