'Program MAGIC.BAS from an idea in
'the "Daily Mail" written by Alan
'Ogden Dec. 1993 for PBasic.
cls:'Thanks again to B.J.Gleason.
?"In a Magic Square there are nine"
?"numbers which add up to the same sum"
?"across, down or diagonally."
8 ?"Choose an ODD number above 5 in"
?"increments of 4 for the seed";:input N
if N < 5 then goto 8
if (N-1)/4 <> int((N-1)/4) then goto 8
if int(N/2) = N/2 then goto 8
I = (N-1)/4
D1 = N - I: D2 = D1 - I:D3 = D2 -I
D4 = D3 - I : U1 = N + I: U2 = U1 + I
U3 = U2 + I : U4 = U3 + I
cls
?"Here is your Magic Square :-"
?,U1;" ";D4;" ";U3;tab(24);"The sum in"
?,U2;" ";N;" ";D2;tab(24);"any direction"
?,D3;" ";U4;" "D1;tab(24);"is "; N * 3
?:?"It's Magic!"
end