The question is-

> 
> Find the smallest number which leaves remainder $8,12$ when divided by $28$ and $32$.
> 
> 
> 

My book gives directly a formula:

> 
> Required number $= \mathrm{lcm}(\text{the two numbers; here}\ 28\ \text{and}\ 32) - \text{Sum of their remainders}$
> 
> 
> 

without any proof.

I am not able to derive the proof or find a generalized form of this. I am also wondering what would happen if the numbers remain the same but the remainders are interchanged. Will the same method continue?

Any help is appreciated.