Logic fix for Magic Square Equation

Wrong equations were being generated, now fixed