To factor $ 5y-40+xy-8x $ we can use factoring by grouping.
Group $ \color{blue}{ 5y }$ with $ \color{blue}{ -40 }$ and $ \color{red}{ xy }$ with $ \color{red}{ -8x }$ then factor each group.
$$ \begin{aligned} 5y-40+xy-8x &= ( \color{blue}{ 5y-40 } ) + ( \color{red}{ xy-8x }) = \\ &= \color{blue}{ 5( y-8 )} + \color{red}{ x( y-8 ) } = \\ &= (5+x)(y-8) \end{aligned} $$