Magic Rectangle


A magic rectangle of size m*n is magic when all it rows sum up to the same magic constant and all its columns sum up to the same magic constant (note: these magic constants are different). The magic constant for the rows can be calculated using the formula $$N_{n,m} = \frac{m}{2}(mn+1)$$ and the magic constant for the columns is $$N_{n,m} = \frac{m}{2}(mn+1)$$. Magic rectangles can only exist when $$m \equiv n$$ (mod 2) and (m,n)$$\neq$$(2,2). For example, if m=3 and n=5 this would suffice, as 5/3 leaves a remainder of 2 and (m,n)=(3,5).This is only the case for rectangles that are symmetric around their centers, these only occur with odd lengthened rows and columns.