The complete symbolic solution for an N×N square in which every row, every column and every diagonal — including the broken (wrapped) ones — sums to N·M. Cells shown in amber are the free parameters; the rest are forced.
N·M