After closely scrutinizing your formula, I understood how they work...it's really amazing...(before today I did not know MOD function can do such things)
What it needs to come up with such formula? Continuous practice, dealing with different case studies...what else?