Vorige Pagina About the Author

' Generates Franklin Squares of order 16, magic sum 2056

' Tested with Office 2007 under Windows 7

Sub MgcSqr16a()

Dim a(256), b(256), c(256)

y = MsgBox("Locked", vbCritical, "Routine MgcSqr16a")
End

n2 = 0: n9 = 0
m1 = 1: m2 = 256: s1 = 2056

'   Generate data
    
    Sheets("Klad1").Select
    
    t1 = Timer

For j256 = 65 To 65                                                 'a(256)
If b(j256) = 0 Then b(j256) = j256: c(256) = j256 Else GoTo 2560
a(256) = j256
For j255 = 96 To 96                                                 'a(255)
If b(j255) = 0 Then b(j255) = j255: c(255) = j255 Else GoTo 2550
a(255) = j255
For j254 = 97 To 97                                                 'a(254)
If b(j254) = 0 Then b(j254) = j254: c(254) = j254 Else GoTo 2540
a(254) = j254
For j253 = 128 To 128                                               'a(253)
If b(j253) = 0 Then b(j253) = j253: c(253) = j253 Else GoTo 2530
a(253) = j253
For j252 = 129 To 129                                               'a(252)
If b(j252) = 0 Then b(j252) = j252: c(252) = j252 Else GoTo 2520
a(252) = j252

jj = 252
a(251) = 514 - a(252) - a(253) - a(254)
j = 251: GoSub 3000: If fl1 = 1 Then GoTo 2520

For j250 = 161 To 161                                               'a(250)
If b(j250) = 0 Then b(j250) = j250: c(250) = j250 Else GoTo 2500
a(250) = j250

jj = 250
a(249) = 514 - a(250) - a(255) - a(256)
j = 249: GoSub 3000: If fl1 = 1 Then GoTo 2500

For j248 = 193 To 193                                               'a(248)
If b(j248) = 0 Then b(j248) = j248: c(248) = j248 Else GoTo 2480
a(248) = j248
For j247 = 224 To 224                                               'a(247)
If b(j247) = 0 Then b(j247) = j247: c(247) = j247 Else GoTo 2470
a(247) = j247
For j246 = 225 To 225                                               'a(246)
If b(j246) = 0 Then b(j246) = j246: c(246) = j246 Else GoTo 2460
a(246) = j246
For j245 = 256 To 256                                               'a(245)
If b(j245) = 0 Then b(j245) = j245: c(245) = j245 Else GoTo 2450
a(245) = j245
For j244 = 1 To 1                                                   'a(244)
If b(j244) = 0 Then b(j244) = j244: c(244) = j244 Else GoTo 2440
a(244) = j244

jj = 244
a(243) = 514 - a(244) - a(245) - a(246)
j = 243: GoSub 3000: If fl1 = 1 Then GoTo 2440
a(242) = -a(244) - a(246) - a(248) + a(250) + a(252) + a(254) + a(256)
j = 242: GoSub 3000: If fl1 = 1 Then GoTo 2440
a(241) = 514 + a(244) + a(246) - a(247) - a(250) - a(252) - a(254) - a(256)
j = 241: GoSub 3000: If fl1 = 1 Then GoTo 2440

For j240 = 191 To 191                                               'a(240)
If b(j240) = 0 Then b(j240) = j240: c(240) = j240 Else GoTo 2400
a(240) = j240

jj = 240
a(239) = 514 - a(240) - a(255) - a(256): j = 239: GoSub 3000: If fl1 = 1 Then GoTo 2400
a(238) = a(240) - a(254) + a(256): j = 238: GoSub 3000: If fl1 = 1 Then GoTo 2400
a(237) = 514 - a(240) - a(253) - a(256): j = 237: GoSub 3000: If fl1 = 1 Then GoTo 2400
a(236) = a(240) - a(252) + a(256): j = 236: GoSub 3000: If fl1 = 1 Then GoTo 2400
a(235) = -a(240) + a(252) + a(253) + a(254) - a(256): j = 235: GoSub 3000: If fl1 = 1 Then GoTo 2400
a(234) = a(240) - a(250) + a(256): j = 234: GoSub 3000: If fl1 = 1 Then GoTo 2400
a(233) = -a(240) + a(250) + a(255): j = 233: GoSub 3000: If fl1 = 1 Then GoTo 2400
a(232) = a(240) - a(248) + a(256): j = 232: GoSub 3000: If fl1 = 1 Then GoTo 2400
a(231) = 514 - a(240) - a(247) - a(256): j = 231: GoSub 3000: If fl1 = 1 Then GoTo 2400
a(230) = a(240) - a(246) + a(256): j = 230: GoSub 3000: If fl1 = 1 Then GoTo 2400
a(229) = 514 - a(240) - a(245) - a(256): j = 229: GoSub 3000: If fl1 = 1 Then GoTo 2400
a(228) = a(240) - a(244) + a(256): j = 228: GoSub 3000: If fl1 = 1 Then GoTo 2400
a(227) = -a(240) + a(244) + a(245) + a(246) - a(256): j = 227: GoSub 3000: If fl1 = 1 Then GoTo 2400
a(226) = a(240) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254)
j = 226: GoSub 3000: If fl1 = 1 Then GoTo 2400
a(225) = -a(240) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254)
j = 225: GoSub 3000: If fl1 = 1 Then GoTo 2400

For j224 = 67 To 67                                                 'a(224)
If b(j224) = 0 Then b(j224) = j224: c(224) = j224 Else GoTo 2240
a(224) = j224

jj = 224
a(223) = -a(224) + a(255) + a(256): j = 223: GoSub 3000: If fl1 = 1 Then GoTo 2240
a(222) = a(224) + a(254) - a(256): j = 222: GoSub 3000: If fl1 = 1 Then GoTo 2240
a(221) = -a(224) + a(253) + a(256): j = 221: GoSub 3000: If fl1 = 1 Then GoTo 2240
a(220) = a(224) + a(252) - a(256): j = 220: GoSub 3000: If fl1 = 1 Then GoTo 2240
a(219) = 514 - a(224) - a(252) - a(253) - a(254) + a(256)
j = 219: GoSub 3000: If fl1 = 1 Then GoTo 2240
a(218) = a(224) + a(250) - a(256): j = 218: GoSub 3000: If fl1 = 1 Then GoTo 2240
a(217) = 514 - a(224) - a(250) - a(255): j = 217: GoSub 3000: If fl1 = 1 Then GoTo 2240
a(216) = a(224) + a(248) - a(256): j = 216: GoSub 3000: If fl1 = 1 Then GoTo 2240
a(215) = -a(224) + a(247) + a(256): j = 215: GoSub 3000: If fl1 = 1 Then GoTo 2240
a(214) = a(224) + a(246) - a(256): j = 214: GoSub 3000: If fl1 = 1 Then GoTo 2240
a(213) = -a(224) + a(245) + a(256): j = 213: GoSub 3000: If fl1 = 1 Then GoTo 2240
a(212) = a(224) + a(244) - a(256): j = 212: GoSub 3000: If fl1 = 1 Then GoTo 2240
a(211) = 514 - a(224) - a(244) - a(245) - a(246) + a(256)
j = 211: GoSub 3000: If fl1 = 1 Then GoTo 2240
a(210) = a(224) - a(244) - a(246) - a(248) + a(250) + a(252) + a(254)
j = 210: GoSub 3000: If fl1 = 1 Then GoTo 2240
a(209) = 514 - a(224) + a(244) + a(246) - a(247) - a(250) - a(252) - a(254)
j = 209: GoSub 3000: If fl1 = 1 Then GoTo 2240

For j208 = 189 To 189                                               'a(208)
If b(j208) = 0 Then b(j208) = j208: c(208) = j208 Else GoTo 2080
a(208) = j208

jj = 208
a(207) = 514 - a(208) - a(255) - a(256): j = 207: GoSub 3000: If fl1 = 1 Then GoTo 2080
a(206) = a(208) - a(254) + a(256): j = 206: GoSub 3000: If fl1 = 1 Then GoTo 2080
a(205) = 514 - a(208) - a(253) - a(256): j = 205: GoSub 3000: If fl1 = 1 Then GoTo 2080
a(204) = a(208) - a(252) + a(256): j = 204: GoSub 3000: If fl1 = 1 Then GoTo 2080
a(203) = -a(208) + a(252) + a(253) + a(254) - a(256): j = 203: GoSub 3000: If fl1 = 1 Then GoTo 2080
a(202) = a(208) - a(250) + a(256): j = 202: GoSub 3000: If fl1 = 1 Then GoTo 2080
a(201) = -a(208) + a(250) + a(255): j = 201: GoSub 3000: If fl1 = 1 Then GoTo 2080
a(200) = a(208) - a(248) + a(256): j = 200: GoSub 3000: If fl1 = 1 Then GoTo 2080
a(199) = 514 - a(208) - a(247) - a(256): j = 199: GoSub 3000: If fl1 = 1 Then GoTo 2080
a(198) = a(208) - a(246) + a(256): j = 198: GoSub 3000: If fl1 = 1 Then GoTo 2080
a(197) = 514 - a(208) - a(245) - a(256): j = 197: GoSub 3000: If fl1 = 1 Then GoTo 2080
a(196) = a(208) - a(244) + a(256): j = 196: GoSub 3000: If fl1 = 1 Then GoTo 2080
a(195) = -a(208) + a(244) + a(245) + a(246) - a(256)
j = 195: GoSub 3000: If fl1 = 1 Then GoTo 2080
a(194) = a(208) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254)
j = 194: GoSub 3000: If fl1 = 1 Then GoTo 2080
a(193) = -a(208) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254)
j = 193: GoSub 3000: If fl1 = 1 Then GoTo 2080

For j192 = 80 To 80                                               'a(192)
If b(j192) = 0 Then b(j192) = j192: c(192) = j192 Else GoTo 1920
a(192) = j192

jj = 192
a(191) = -a(192) + a(255) + a(256): j = 191: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(190) = a(192) + a(254) - a(256): j = 190: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(189) = -a(192) + a(253) + a(256): j = 189: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(188) = a(192) + a(252) - a(256): j = 188: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(187) = 514 - a(192) - a(252) - a(253) - a(254) + a(256)
j = 187: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(186) = a(192) + a(250) - a(256): j = 186: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(185) = 514 - a(192) - a(250) - a(255): j = 185: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(184) = a(192) + a(248) - a(256): j = 184: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(183) = -a(192) + a(247) + a(256): j = 183: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(182) = a(192) + a(246) - a(256): j = 182: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(181) = -a(192) + a(245) + a(256): j = 181: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(180) = a(192) + a(244) - a(256): j = 180: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(179) = 514 - a(192) - a(244) - a(245) - a(246) + a(256)
j = 179: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(178) = a(192) - a(244) - a(246) - a(248) + a(250) + a(252) + a(254)
j = 178: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(177) = 514 - a(192) + a(244) + a(246) - a(247) - a(250) - a(252) - a(254)
j = 177: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(176) = 514 - a(192) - a(208) - a(224): j = 176: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(175) = a(192) + a(208) + a(224) - a(255) - a(256)
j = 175: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(174) = 514 - a(192) - a(208) - a(224) - a(254) + a(256)
j = 174: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(173) = a(192) + a(208) + a(224) - a(253) - a(256)
j = 173: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(172) = 514 - a(192) - a(208) - a(224) - a(252) + a(256)
j = 172: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(171) = -514 + a(192) + a(208) + a(224) + a(252) + a(253) + a(254) - a(256)
j = 171: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(170) = 514 - a(192) - a(208) - a(224) - a(250) + a(256)
j = 170: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(169) = -514 + a(192) + a(208) + a(224) + a(250) + a(255)
j = 169: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(168) = 514 - a(192) - a(208) - a(224) - a(248) + a(256)
j = 168: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(167) = a(192) + a(208) + a(224) - a(247) - a(256)
j = 167: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(166) = 514 - a(192) - a(208) - a(224) - a(246) + a(256)
j = 166: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(165) = a(192) + a(208) + a(224) - a(245) - a(256)
j = 165: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(164) = 514 - a(192) - a(208) - a(224) - a(244) + a(256)
j = 164: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(163) = -514 + a(192) + a(208) + a(224) + a(244) + a(245) + a(246) - a(256)
j = 163: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(162) = 514 - a(192) - a(208) - a(224) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254)
j = 162: GoSub 3000: If fl1 = 1 Then GoTo 1920
a(161) = -514 + a(192) + a(208) + a(224) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254)
j = 161: GoSub 3000: If fl1 = 1 Then GoTo 1920

For j160 = 78 To 78                                               'a(160)
If b(j160) = 0 Then b(j160) = j160: c(160) = j160 Else GoTo 1600
a(160) = j160

jj = 160
a(159) = -a(160) + a(255) + a(256): j = 159: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(158) = a(160) + a(254) - a(256): j = 158: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(157) = -a(160) + a(253) + a(256): j = 157: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(156) = a(160) + a(252) - a(256): j = 156: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(155) = 514 - a(160) - a(252) - a(253) - a(254) + a(256)
j = 155: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(154) = a(160) + a(250) - a(256): j = 154: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(153) = 514 - a(160) - a(250) - a(255): j = 153: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(152) = a(160) + a(248) - a(256): j = 152: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(151) = -a(160) + a(247) + a(256): j = 151: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(150) = a(160) + a(246) - a(256): j = 150: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(149) = -a(160) + a(245) + a(256): j = 149: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(148) = a(160) + a(244) - a(256): j = 148: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(147) = 514 - a(160) - a(244) - a(245) - a(246) + a(256)
j = 147: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(146) = a(160) - a(244) - a(246) - a(248) + a(250) + a(252) + a(254)
j = 146: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(145) = 514 - a(160) + a(244) + a(246) - a(247) - a(250) - a(252) - a(254)
j = 145: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(144) = 514 - a(160) - a(240) - a(256): j = 144: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(143) = a(160) + a(240) - a(255): j = 143: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(142) = 514 - a(160) - a(240) - a(254): j = 142: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(141) = a(160) + a(240) - a(253): j = 141: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(140) = 514 - a(160) - a(240) - a(252): j = 140: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(139) = -514 + a(160) + a(240) + a(252) + a(253) + a(254)
j = 139: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(138) = 514 - a(160) - a(240) - a(250): j = 138: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(137) = -514 + a(160) + a(240) + a(250) + a(255) + a(256)
j = 137: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(136) = 514 - a(160) - a(240) - a(248): j = 136: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(135) = a(160) + a(240) - a(247): j = 135: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(134) = 514 - a(160) - a(240) - a(246): j = 134: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(133) = a(160) + a(240) - a(245): j = 133: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(132) = 514 - a(160) - a(240) - a(244): j = 132: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(131) = -514 + a(160) + a(240) + a(244) + a(245) + a(246)
j = 131: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(130) = 514 - a(160) - a(240) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254) - a(256)
j = 130: GoSub 3000: If fl1 = 1 Then GoTo 1600
a(129) = -514 + a(160) + a(240) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254) + a(256)
j = 129: GoSub 3000: If fl1 = 1 Then GoTo 1600

For j128 = m1 To m2                                               'a(128)
If b(j128) = 0 Then b(j128) = j128: c(128) = j128 Else GoTo 1280
a(128) = j128

jj = 128
a(127) = -a(128) + a(255) + a(256): j = 127: GoSub 3000: If fl1 = 1 Then GoTo 1280
a(126) = a(128) + a(254) - a(256): j = 126: GoSub 3000: If fl1 = 1 Then GoTo 1280
a(125) = -a(128) + a(253) + a(256): j = 125: GoSub 3000: If fl1 = 1 Then GoTo 1280
a(124) = a(128) + a(252) - a(256): j = 124: GoSub 3000: If fl1 = 1 Then GoTo 1280
a(123) = 514 - a(128) - a(252) - a(253) - a(254) + a(256)
j = 123: GoSub 3000: If fl1 = 1 Then GoTo 1280
a(122) = a(128) + a(250) - a(256): j = 122: GoSub 3000: If fl1 = 1 Then GoTo 1280
a(121) = 514 - a(128) - a(250) - a(255): j = 121: GoSub 3000: If fl1 = 1 Then GoTo 1280
a(120) = a(128) + a(248) - a(256): j = 120: GoSub 3000: If fl1 = 1 Then GoTo 1280
a(119) = -a(128) + a(247) + a(256): j = 119: GoSub 3000: If fl1 = 1 Then GoTo 1280
a(118) = a(128) + a(246) - a(256): j = 118: GoSub 3000: If fl1 = 1 Then GoTo 1280
a(117) = -a(128) + a(245) + a(256): j = 117: GoSub 3000: If fl1 = 1 Then GoTo 1280
a(116) = a(128) + a(244) - a(256): j = 116: GoSub 3000: If fl1 = 1 Then GoTo 1280
a(115) = 514 - a(128) - a(244) - a(245) - a(246) + a(256)
j = 115: GoSub 3000: If fl1 = 1 Then GoTo 1280
a(114) = a(128) - a(244) - a(246) - a(248) + a(250) + a(252) + a(254)
j = 114: GoSub 3000: If fl1 = 1 Then GoTo 1280
a(113) = 514 - a(128) + a(244) + a(246) - a(247) - a(250) - a(252) - a(254)
j = 113: GoSub 3000: If fl1 = 1 Then GoTo 1280

For j112 = m1 To m2                                               'a(112)
If b(j112) = 0 Then b(j112) = j112: c(112) = j112 Else GoTo 1120
a(112) = j112

jj = 112
a(111) = 514 - a(112) - a(255) - a(256): j = 111: GoSub 3000: If fl1 = 1 Then GoTo 1120
a(110) = a(112) - a(254) + a(256): j = 110: GoSub 3000: If fl1 = 1 Then GoTo 1120
a(109) = 514 - a(112) - a(253) - a(256): j = 109: GoSub 3000: If fl1 = 1 Then GoTo 1120
a(108) = a(112) - a(252) + a(256): j = 108: GoSub 3000: If fl1 = 1 Then GoTo 1120
a(107) = -a(112) + a(252) + a(253) + a(254) - a(256): j = 107: GoSub 3000: If fl1 = 1 Then GoTo 1120
a(106) = a(112) - a(250) + a(256): j = 106: GoSub 3000: If fl1 = 1 Then GoTo 1120
a(105) = -a(112) + a(250) + a(255): j = 105: GoSub 3000: If fl1 = 1 Then GoTo 1120
a(104) = a(112) - a(248) + a(256): j = 104: GoSub 3000: If fl1 = 1 Then GoTo 1120
a(103) = 514 - a(112) - a(247) - a(256): j = 103: GoSub 3000: If fl1 = 1 Then GoTo 1120
a(102) = a(112) - a(246) + a(256): j = 102: GoSub 3000: If fl1 = 1 Then GoTo 1120
a(101) = 514 - a(112) - a(245) - a(256): j = 101: GoSub 3000: If fl1 = 1 Then GoTo 1120
a(100) = a(112) - a(244) + a(256): j = 100: GoSub 3000: If fl1 = 1 Then GoTo 1120
a(99) = -a(112) + a(244) + a(245) + a(246) - a(256): j = 99: GoSub 3000: If fl1 = 1 Then GoTo 1120
a(98) = a(112) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254)
j = 98: GoSub 3000: If fl1 = 1 Then GoTo 1120
a(97) = -a(112) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254)
j = 97: GoSub 3000: If fl1 = 1 Then GoTo 1120

For j96 = m1 To m2                                               'a(96)
If b(j96) = 0 Then b(j96) = j96: c(96) = j96 Else GoTo 960
a(96) = j96

jj = 96
a(95) = -a(96) + a(255) + a(256): j = 95: GoSub 3000: If fl1 = 1 Then GoTo 960
a(94) = a(96) + a(254) - a(256): j = 94: GoSub 3000: If fl1 = 1 Then GoTo 960
a(93) = -a(96) + a(253) + a(256): j = 93: GoSub 3000: If fl1 = 1 Then GoTo 960
a(92) = a(96) + a(252) - a(256): j = 92: GoSub 3000: If fl1 = 1 Then GoTo 960
a(91) = 514 - a(96) - a(252) - a(253) - a(254) + a(256): j = 91: GoSub 3000: If fl1 = 1 Then GoTo 960
a(90) = a(96) + a(250) - a(256): j = 90: GoSub 3000: If fl1 = 1 Then GoTo 960
a(89) = 514 - a(96) - a(250) - a(255): j = 89: GoSub 3000: If fl1 = 1 Then GoTo 960
a(88) = a(96) + a(248) - a(256): j = 88: GoSub 3000: If fl1 = 1 Then GoTo 960
a(87) = -a(96) + a(247) + a(256): j = 87: GoSub 3000: If fl1 = 1 Then GoTo 960
a(86) = a(96) + a(246) - a(256): j = 86: GoSub 3000: If fl1 = 1 Then GoTo 960
a(85) = -a(96) + a(245) + a(256): j = 85: GoSub 3000: If fl1 = 1 Then GoTo 960
a(84) = a(96) + a(244) - a(256): j = 84: GoSub 3000: If fl1 = 1 Then GoTo 960
a(83) = 514 - a(96) - a(244) - a(245) - a(246) + a(256): j = 83: GoSub 3000: If fl1 = 1 Then GoTo 960
a(82) = a(96) - a(244) - a(246) - a(248) + a(250) + a(252) + a(254)
j = 82: GoSub 3000: If fl1 = 1 Then GoTo 960
a(81) = 514 - a(96) + a(244) + a(246) - a(247) - a(250) - a(252) - a(254)
j = 81: GoSub 3000: If fl1 = 1 Then GoTo 960

For j80 = m1 To m2                                               'a(80)
If b(j80) = 0 Then b(j80) = j80: c(80) = j80 Else GoTo 800
a(80) = j80

jj = 80
a(79) = 514 - a(80) - a(255) - a(256): j = 79: GoSub 3000: If fl1 = 1 Then GoTo 800
a(78) = a(80) - a(254) + a(256): j = 78: GoSub 3000: If fl1 = 1 Then GoTo 800
a(77) = 514 - a(80) - a(253) - a(256): j = 77: GoSub 3000: If fl1 = 1 Then GoTo 800
a(76) = a(80) - a(252) + a(256): j = 76: GoSub 3000: If fl1 = 1 Then GoTo 800
a(75) = -a(80) + a(252) + a(253) + a(254) - a(256): j = 75: GoSub 3000: If fl1 = 1 Then GoTo 800
a(74) = a(80) - a(250) + a(256): j = 74: GoSub 3000: If fl1 = 1 Then GoTo 800
a(73) = -a(80) + a(250) + a(255): j = 73: GoSub 3000: If fl1 = 1 Then GoTo 800
a(72) = a(80) - a(248) + a(256): j = 72: GoSub 3000: If fl1 = 1 Then GoTo 800
a(71) = 514 - a(80) - a(247) - a(256): j = 71: GoSub 3000: If fl1 = 1 Then GoTo 800
a(70) = a(80) - a(246) + a(256): j = 70: GoSub 3000: If fl1 = 1 Then GoTo 800
a(69) = 514 - a(80) - a(245) - a(256): j = 69: GoSub 3000: If fl1 = 1 Then GoTo 800
a(68) = a(80) - a(244) + a(256): j = 68: GoSub 3000: If fl1 = 1 Then GoTo 800
a(67) = -a(80) + a(244) + a(245) + a(246) - a(256): j = 67: GoSub 3000: If fl1 = 1 Then GoTo 800
a(66) = a(80) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254)
j = 66: GoSub 3000: If fl1 = 1 Then GoTo 800
a(65) = -a(80) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254)
j = 65: GoSub 3000: If fl1 = 1 Then GoTo 800

For j64 = m1 To m2                                               'a(64)
If b(j64) = 0 Then b(j64) = j64: c(64) = j64 Else GoTo 640
a(64) = j64

jj = 64
a(63) = -a(64) + a(255) + a(256): j = 63: GoSub 3000: If fl1 = 1 Then GoTo 640
a(62) = a(64) + a(254) - a(256): j = 62: GoSub 3000: If fl1 = 1 Then GoTo 640
a(61) = -a(64) + a(253) + a(256): j = 61: GoSub 3000: If fl1 = 1 Then GoTo 640
a(60) = a(64) + a(252) - a(256): j = 60: GoSub 3000: If fl1 = 1 Then GoTo 640
a(59) = 514 - a(64) - a(252) - a(253) - a(254) + a(256): j = 59: GoSub 3000: If fl1 = 1 Then GoTo 640
a(58) = a(64) + a(250) - a(256): j = 58: GoSub 3000: If fl1 = 1 Then GoTo 640
a(57) = 514 - a(64) - a(250) - a(255): j = 57: GoSub 3000: If fl1 = 1 Then GoTo 640
a(56) = a(64) + a(248) - a(256): j = 56: GoSub 3000: If fl1 = 1 Then GoTo 640
a(55) = -a(64) + a(247) + a(256): j = 55: GoSub 3000: If fl1 = 1 Then GoTo 640
a(54) = a(64) + a(246) - a(256): j = 54: GoSub 3000: If fl1 = 1 Then GoTo 640
a(53) = -a(64) + a(245) + a(256): j = 53: GoSub 3000: If fl1 = 1 Then GoTo 640
a(52) = a(64) + a(244) - a(256): j = 52: GoSub 3000: If fl1 = 1 Then GoTo 640
a(51) = 514 - a(64) - a(244) - a(245) - a(246) + a(256): j = 51: GoSub 3000: If fl1 = 1 Then GoTo 640
a(50) = a(64) - a(244) - a(246) - a(248) + a(250) + a(252) + a(254)
j = 50: GoSub 3000: If fl1 = 1 Then GoTo 640
a(49) = 514 - a(64) + a(244) + a(246) - a(247) - a(250) - a(252) - a(254)
j = 49: GoSub 3000: If fl1 = 1 Then GoTo 640
a(48) = 514 - a(64) - a(80) - a(96): j = 48: GoSub 3000: If fl1 = 1 Then GoTo 640
a(47) = a(64) + a(80) + a(96) - a(255) - a(256): j = 47: GoSub 3000: If fl1 = 1 Then GoTo 640
a(46) = 514 - a(64) - a(80) - a(96) - a(254) + a(256): j = 46: GoSub 3000: If fl1 = 1 Then GoTo 640
a(45) = a(64) + a(80) + a(96) - a(253) - a(256): j = 45: GoSub 3000: If fl1 = 1 Then GoTo 640
a(44) = 514 - a(64) - a(80) - a(96) - a(252) + a(256): j = 44: GoSub 3000: If fl1 = 1 Then GoTo 640
a(43) = -514 + a(64) + a(80) + a(96) + a(252) + a(253) + a(254) - a(256)
j = 43: GoSub 3000: If fl1 = 1 Then GoTo 640
a(42) = 514 - a(64) - a(80) - a(96) - a(250) + a(256): j = 42: GoSub 3000: If fl1 = 1 Then GoTo 640
a(41) = -514 + a(64) + a(80) + a(96) + a(250) + a(255): j = 41: GoSub 3000: If fl1 = 1 Then GoTo 640
a(40) = 514 - a(64) - a(80) - a(96) - a(248) + a(256): j = 40: GoSub 3000: If fl1 = 1 Then GoTo 640
a(39) = a(64) + a(80) + a(96) - a(247) - a(256): j = 39: GoSub 3000: If fl1 = 1 Then GoTo 640
a(38) = 514 - a(64) - a(80) - a(96) - a(246) + a(256): j = 38: GoSub 3000: If fl1 = 1 Then GoTo 640
a(37) = a(64) + a(80) + a(96) - a(245) - a(256): j = 37: GoSub 3000: If fl1 = 1 Then GoTo 640
a(36) = 514 - a(64) - a(80) - a(96) - a(244) + a(256): j = 36: GoSub 3000: If fl1 = 1 Then GoTo 640
a(35) = -514 + a(64) + a(80) + a(96) + a(244) + a(245) + a(246) - a(256)
j = 35: GoSub 3000: If fl1 = 1 Then GoTo 640
a(34) = 514 - a(64) - a(80) - a(96) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254)
j = 34: GoSub 3000: If fl1 = 1 Then GoTo 640
a(33) = -514 + a(64) + a(80) + a(96) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254)
j = 33: GoSub 3000: If fl1 = 1 Then GoTo 640
a(32) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) + a(256)
j = 32: GoSub 3000: If fl1 = 1 Then GoTo 640
a(31) = a(64) + a(96) + a(128) - a(160) - a(192) - a(224) + a(255)
j = 31: GoSub 3000: If fl1 = 1 Then GoTo 640
a(30) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) + a(254)
j = 30: GoSub 3000: If fl1 = 1 Then GoTo 640
a(29) = a(64) + a(96) + a(128) - a(160) - a(192) - a(224) + a(253)
j = 29: GoSub 3000: If fl1 = 1 Then GoTo 640
a(28) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) + a(252)
j = 28: GoSub 3000: If fl1 = 1 Then GoTo 640
a(27) = 514 + a(64) + a(96) + a(128) - a(160) - a(192) - a(224) - a(252) - a(253) - a(254)
j = 27: GoSub 3000: If fl1 = 1 Then GoTo 640
a(26) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) + a(250)
j = 26: GoSub 3000: If fl1 = 1 Then GoTo 640
a(25) = 514 + a(64) + a(96) + a(128) - a(160) - a(192) - a(224) - a(250) - a(255) - a(256)
j = 25: GoSub 3000: If fl1 = 1 Then GoTo 640
a(24) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) + a(248)
j = 24: GoSub 3000: If fl1 = 1 Then GoTo 640
a(23) = a(64) + a(96) + a(128) - a(160) - a(192) - a(224) + a(247)
j = 23: GoSub 3000: If fl1 = 1 Then GoTo 640
a(22) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) + a(246)
j = 22: GoSub 3000: If fl1 = 1 Then GoTo 640
a(21) = a(64) + a(96) + a(128) - a(160) - a(192) - a(224) + a(245)
j = 21: GoSub 3000: If fl1 = 1 Then GoTo 640
a(20) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) + a(244)
j = 20: GoSub 3000: If fl1 = 1 Then GoTo 640
a(19) = 514 + a(64) + a(96) + a(128) - a(160) - a(192) - a(224) - a(244) - a(245) - a(246)
j = 19: GoSub 3000: If fl1 = 1 Then GoTo 640
a(18) = -a(64) - a(96) - a(128) + a(160) + a(192) + a(224) - a(244) - a(246) - a(248) + a(250) + a(252) + a(254) + a(256)
j = 18: GoSub 3000: If fl1 = 1 Then GoTo 640
a(17) = 514 + a(64) + a(96) + a(128) - a(160) - a(192) - a(224) + a(244) + a(246) - a(247) - a(250) - a(252) - a(254) - a(256)
j = 17: GoSub 3000: If fl1 = 1 Then GoTo 640
a(16) = 514 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) - a(256)
j = 16: GoSub 3000: If fl1 = 1 Then GoTo 640
a(15) = -a(64) - a(96) + a(112) + a(160) + a(192) + a(224) - a(255)
j = 15: GoSub 3000: If fl1 = 1 Then GoTo 640
a(14) = 514 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) - a(254)
j = 14: GoSub 3000: If fl1 = 1 Then GoTo 640
a(13) = -a(64) - a(96) + a(112) + a(160) + a(192) + a(224) - a(253)
j = 13: GoSub 3000: If fl1 = 1 Then GoTo 640
a(12) = 514 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) - a(252)
j = 12: GoSub 3000: If fl1 = 1 Then GoTo 640
a(11) = -514 - a(64) - a(96) + a(112) + a(160) + a(192) + a(224) + a(252) + a(253) + a(254)
j = 11: GoSub 3000: If fl1 = 1 Then GoTo 640
a(10) = 514 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) - a(250)
j = 10: GoSub 3000: If fl1 = 1 Then GoTo 640
a(9) = -514 - a(64) - a(96) + a(112) + a(160) + a(192) + a(224) + a(250) + a(255) + a(256)
j = 9: GoSub 3000: If fl1 = 1 Then GoTo 640
a(8) = 514 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) - a(248)
j = 8: GoSub 3000: If fl1 = 1 Then GoTo 640
a(7) = -a(64) - a(96) + a(112) + a(160) + a(192) + a(224) - a(247)
j = 7: GoSub 3000: If fl1 = 1 Then GoTo 640
a(6) = 514 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) - a(246)
j = 6: GoSub 3000: If fl1 = 1 Then GoTo 640
a(5) = -a(64) - a(96) + a(112) + a(160) + a(192) + a(224) - a(245)
j = 5: GoSub 3000: If fl1 = 1 Then GoTo 640
a(4) = 514 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) - a(244)
j = 4: GoSub 3000: If fl1 = 1 Then GoTo 640
a(3) = -514 - a(64) - a(96) + a(112) + a(160) + a(192) + a(224) + a(244) + a(245) + a(246)
j = 3: GoSub 3000: If fl1 = 1 Then GoTo 640
a(2) = 514 + a(64) + a(96) - a(112) - a(160) - a(192) - a(224) + a(244) + a(246) + a(248) - a(250) - a(252) - a(254) - a(256)
j = 2: GoSub 3000: If fl1 = 1 Then GoTo 640
a(1) = -514 - a(64) - a(96) + a(112) + a(160) + a(192) + a(224) - a(244) - a(246) + a(247) + a(250) + a(252) + a(254) + a(256)
j = 1: GoSub 3000: If fl1 = 1 Then GoTo 640

                                    n9 = n9 + 1
                                    GoSub 2650 'Print results (squares)
'                                   GoSub 2645 'Print results (selected numbers

     jj = 64: GoSub 3050           'Reset b() and c()
640 Next j64

     jj = 80: GoSub 3050           'Reset b() and c()
800 Next j80

     jj = 96: GoSub 3050           'Reset b() and c()
960 Next j96

     jj = 112: GoSub 3050          'Reset b() and c()
1120 Next j112

     jj = 128: GoSub 3050          'Reset b() and c()
1280 Next j128

     jj = 160: GoSub 3050          'Reset b() and c()
1600 Next j160

     jj = 192: GoSub 3050          'Reset b() and c()
1920 Next j192
     
     jj = 208: GoSub 3050          'Reset b() and c()
2080 Next j208

     jj = 224: GoSub 3050          'Reset b() and c()
2240 Next j224

     jj = 240: GoSub 3050          'Reset b() and c()
2400 Next j240

     jj = 244: GoSub 3050          'Reset b() and c()
2440 Next j244
     b(c(245)) = 0: c(245) = 0
2450 Next j245
     b(c(246)) = 0: c(246) = 0
2460 Next j246
     b(c(247)) = 0: c(247) = 0
2470 Next j247
     b(c(248)) = 0: c(248) = 0
2480 Next j248

     jj = 250: GoSub 3050          'Reset b() and c()
2500 Next j250

     jj = 252: GoSub 3050          'Reset b() and c()
2520 Next j252
     b(c(253)) = 0: c(253) = 0
2530 Next j253
     b(c(254)) = 0: c(254) = 0
2540 Next j254
     b(c(255)) = 0: c(255) = 0
2550 Next j255
     b(c(256)) = 0: c(256) = 0
2560 Next j256

    t2 = Timer
    
    t10 = Str(t2 - t1) + " sec., " + Str(n9) + " Solutions for sum" + Str(s1)
    y = MsgBox(t10, 0, "Routine MgcSqr16a")

End

'   Print results (selected numbers)

2645 For i1 = 1 To 256
         Cells(n9, i1).Value = a(i1)
     Next i1
    
     Return

'   Print results (squares)

2650 n2 = n2 + 1
     If n2 = 3 Then
         n2 = 1: k1 = k1 + 17: k2 = 0
     Else
         If n9 > 1 Then k2 = k2 + 17
     End If
     Cells(k1 + 1, k2 + 1).Select
    
     i3 = 0
     For i1 = 1 To 16
         For i2 = 1 To 16
             i3 = i3 + 1
             Cells(k1 + i1, k2 + i2).Value = a(i3)
         Next i2
     Next i1
    
     Return
     
'    Exclude identical solutions and solutions out of range
     
3000 fl1 = 0
     If a(j) <= 0 Or a(j) > 256 Then fl1 = 1: GoTo 3010
     If b(a(j)) = 0 Then b(a(j)) = a(j): c(j) = a(j) Else fl1 = 1
3010 If fl1 = 1 Then                                               'Reset b() and c()
        For i = j + 1 To jj
             b(c(i)) = 0: c(i) = 0
        Next i
     End If
     Return

'    Reset b() and c() after completion loop

3050 For i = j To jj
         b(c(i)) = 0: c(i) = 0
     Next i
     Return

End Sub

Vorige Pagina About the Author