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.
This formula isn't true, actually it works just in some cases, yours for example. This is because if $x$ is the required number then working modulo $28$, we have: $x \equiv -20 \pmod{28}$, which coincidentally is equal to $8$ modulo $28$. Try this formula for $22$ and $18$ and respecitve remainders of $5$ and $3$ and you will notice that it doesn't work
To find such a number (which sometimes might not exist) you need to solve the following congurence relations
$$x \equiv 12 \pmod{32} \implies x = 32t + 12$$ $$x \equiv 8 \pmod{28} \implies x = 28s + 8$$
Equating them and solving them you get:
$$32t + 12 = 28s + 8$$ $$28s \equiv 4 \pmod {32}$$ $$7s \equiv 1 \pmod 8 \implies s \equiv 7 \pmod 8 \implies s = 8k + 7$$
Substituting you will get $x = 28(8k + 7) + 8 = 224k + 204$. So the smallest two numbers satisfying the condition are $204$ and $428$.