Vorige Pagina About the Author

' Generates Inlaid Magic Squares of order 25
' Based on Order 5 Magic Sub Squares with Different Magic Sums

' Tested with Office 2007 under Windows 7

Sub Priem25k()

Dim a1(750), a(25), a25(625), b1(48355), b(48355), c(25)

y = MsgBox("Locked", vbCritical, "Routine Priem25k")
End
    
    n1 = 0: n9 = 0: n10 = 0: k1 = 1: k2 = 1
    
    Sheets("Klad1").Select
    
    t1 = Timer

For j200 = 603 To 1292
s25 = Sheets("Input25").Cells(j200, 52).Value

Erase a25

'Define Center Elements

For i1 = 1 To 25
    a(i1) = Sheets("Input25").Cells(j200, i1).Value
Next i1
a25(53) = a(1):   a25(58) = a(2):   a25(63) = a(3):   a25(68) = a(4):   a25(73) = a(5):
a25(178) = a(6):  a25(183) = a(7):  a25(188) = a(8):  a25(193) = a(9):  a25(198) = a(10):
a25(303) = a(11): a25(308) = a(12): a25(313) = a(13): a25(318) = a(14): a25(323) = a(15):
a25(428) = a(16): a25(433) = a(17): a25(438) = a(18): a25(443) = a(19): a25(448) = a(20):
a25(553) = a(21): a25(558) = a(22): a25(563) = a(23): a25(568) = a(24): a25(573) = a(25):

Erase a

For j101 = 27 To 51
j100 = Sheets("Input25").Cells(j200, j101).Value

'   Define variables

    Cntr3 = Sheets("Pairs7").Cells(j100, 6).Value      'Mid
    s1 = 5 * Cntr3
    nVar1 = Sheets("Pairs7").Cells(j100, 9).Value
   
    For i1 = 1 To nVar1
        a1(i1) = Sheets("Pairs7").Cells(j100, 9 + i1).Value
    Next i1
    m1 = 1: m2 = nVar1
    If a1(1) = 1 Then m1 = 2: m2 = m2 - 1
    
    Erase b1
    For i1 = m1 To m2
        b1(a1(i1)) = a1(i1)
    Next i1

'   Remove Used Primes

    For i1 = 1 To 625
        b1(a25(i1)) = 0
    Next i1

'   Generate Squares (5 x 5)

a(13) = 0.2 * s1: b(a(13)) = a(13)

For j23 = m1 To m2                                          'a(23)  Diamond
If b1(a1(j23)) = 0 Then GoTo 230
If b(a1(j23)) = 0 Then b(a1(j23)) = a1(j23): c(23) = a1(j23) Else GoTo 230
a(23) = a1(j23)

a(3) = 0.4 * s1 - a(23)
If a(3) < a1(m1) Or a(3) > a1(m2) Then GoTo 30
If b1(a(3)) = 0 Then GoTo 30
If b(a(3)) = 0 Then b(a(3)) = a(3): c(3) = a(3) Else GoTo 30

For j19 = m1 To m2                                           'a(19) Diamond
If b1(a1(j19)) = 0 Then GoTo 190
If b(a1(j19)) = 0 Then b(a1(j19)) = a1(j19): c(19) = a1(j19) Else GoTo 190
a(19) = a1(j19)

a(17) = 0.8 * s1 - a(19) - 2 * a(23)
If a(17) < a1(m1) Or a(17) > a1(m2) Then GoTo 170
If b1(a(17)) = 0 Then GoTo 170
If b(a(17)) = 0 Then b(a(17)) = a(17): c(17) = a(17) Else GoTo 170

a(15) = 0.6 * s1 - a(19) - a(23)
If a(15) < a1(m1) Or a(15) > a1(m2) Then GoTo 150
If b1(a(15)) = 0 Then GoTo 150
If b(a(15)) = 0 Then b(a(15)) = a(15): c(15) = a(15) Else GoTo 150

a(11) = 0.4 * s1 - a(15)
If a(11) < a1(m1) Or a(11) > a1(m2) Then GoTo 110:
If b1(a(11)) = 0 Then GoTo 110
If b(a(11)) = 0 Then b(a(11)) = a(11): c(11) = a(11) Else GoTo 110

a(9) = 0.4 * s1 - a(17)
If a(9) < a1(m1) Or a(9) > a1(m2) Then GoTo 90
If b1(a(9)) = 0 Then GoTo 90
If b(a(9)) = 0 Then b(a(9)) = a(9): c(9) = a(9) Else GoTo 90

a(7) = 0.4 * s1 - a(19)
If a(7) < a1(m1) Or a(7) > a1(m2) Then GoTo 70
If b1(a(7)) = 0 Then GoTo 70
If b(a(7)) = 0 Then b(a(7)) = a(7): c(7) = a(7) Else GoTo 70

For j25 = m1 To m2                                          'a(25)  Remainder
If b1(a1(j25)) = 0 Then GoTo 250
If b(a1(j25)) = 0 Then b(a1(j25)) = a1(j25): c(25) = a1(j25) Else GoTo 250
a(25) = a1(j25)

a(1) = 0.4 * s1 - a(25)
If a(1) < a1(m1) Or a(1) > a1(m2) Then GoTo 10
If b1(a(1)) = 0 Then GoTo 10
If b(a(1)) = 0 Then b(a(1)) = a(1): c(1) = a(1) Else GoTo 10

For j24 = m1 To m2                                          'a(24)
If b1(a1(j24)) = 0 Then GoTo 240
If b(a1(j24)) = 0 Then b(a1(j24)) = a1(j24): c(24) = a1(j24) Else GoTo 240
a(24) = a1(j24)

a(2) = 0.4 * s1 - a(24)
If a(2) < a1(m1) Or a(2) > a1(m2) Then GoTo 20
If b1(a(2)) = 0 Then GoTo 20
If b(a(2)) = 0 Then b(a(2)) = a(2): c(2) = a(2) Else GoTo 20

For j22 = m1 To m2                                          'a(22)
If b1(a1(j22)) = 0 Then GoTo 220
If b(a1(j22)) = 0 Then b(a1(j22)) = a1(j22): c(22) = a1(j22) Else GoTo 220
a(22) = a1(j22)

a(21) = s1 - a(22) - a(23) - a(24) - a(25)
If a(21) < a1(m1) Or a(21) > a1(m2) Then GoTo 210
If b1(a(21)) = 0 Then GoTo 210
If b(a(21)) = 0 Then b(a(21)) = a(21): c(21) = a(21) Else GoTo 210

a(5) = 0.4 * s1 - a(21)
If a(5) < a1(m1) Or a(5) > a1(m2) Then GoTo 50
If b1(a(5)) = 0 Then GoTo 50
If b(a(5)) = 0 Then b(a(5)) = a(5): c(5) = a(5) Else GoTo 50

a(4) = 0.4 * s1 - a(22)
If a(4) < a1(m1) Or a(4) > a1(m2) Then GoTo 40
If b1(a(4)) = 0 Then GoTo 40
If b(a(4)) = 0 Then b(a(4)) = a(4): c(4) = a(4) Else GoTo 40

a(14) = s1 - 2 * a(19) + a(22) - 2 * a(23) - a(24)
If a(14) < a1(m1) Or a(14) > a1(m2) Then GoTo 140
If b1(a(14)) = 0 Then GoTo 140
If b(a(14)) = 0 Then b(a(14)) = a(14): c(14) = a(14) Else GoTo 140

a(12) = 0.4 * s1 - a(14)
If a(12) < a1(m1) Or a(12) > a1(m2) Then GoTo 120
If b1(a(12)) = 0 Then GoTo 120
If b(a(12)) = 0 Then b(a(12)) = a(12): c(12) = a(12) Else GoTo 120

For j20 = m1 To m2                                          'a(20)
If b1(a1(j20)) = 0 Then GoTo 200
If b(a1(j20)) = 0 Then b(a1(j20)) = a1(j20): c(20) = a1(j20) Else GoTo 200
a(20) = a1(j20)

a(6) = 2 * s1 / 5 - a(20)
If a(6) < a1(m1) Or a(6) > a1(m2) Then GoTo 60
If b1(a(6)) = 0 Then GoTo 60
If b(a(6)) = 0 Then b(a(6)) = a(6): c(6) = a(6) Else GoTo 60

a(16) = -0.6 * s1 - a(19) + a(20) + a(22) + a(24) + 2 * a(25)
If a(16) < a1(m1) Or a(16) > a1(m2) Then GoTo 160
If b1(a(16)) = 0 Then GoTo 160
If b(a(16)) = 0 Then b(a(16)) = a(16): c(16) = a(16) Else GoTo 160

a(10) = 2 * s1 / 5 - a(16)
If a(10) < a1(m1) Or a(10) > a1(m2) Then GoTo 100:
If b1(a(10)) = 0 Then GoTo 100
If b(a(10)) = 0 Then b(a(10)) = a(10): c(10) = a(10) Else GoTo 100

a(18) = 0.8 * s1 + a(19) - 2 * a(20) - a(22) + 2 * a(23) - a(24) - 2 * a(25)
If a(18) < a1(m1) Or a(18) > a1(m2) Then GoTo 180
If b1(a(18)) = 0 Then GoTo 180
If b(a(18)) = 0 Then b(a(18)) = a(18): c(18) = a(18) Else GoTo 180

a(8) = 0.4 * s1 - a(18)
If a(8) < a1(m1) Or a(8) > a1(m2) Then GoTo 80
If b1(a(8)) = 0 Then GoTo 80
If b(a(8)) = 0 Then b(a(8)) = a(8): c(8) = a(8) Else GoTo 80

'                         Exclude solutions with identical numbers

                          GoSub 800: If fl1 = 0 Then GoTo 75
                          n10 = n10 + 1: GoSub 750            'Assign to a25()
                         
                          Erase b, c: GoTo 5                  'Assign only first square
75                          
    b(c(8)) = 0: c(8) = 0
80  b(c(18)) = 0: c(18) = 0
180 b(c(10)) = 0: c(10) = 0
100 b(c(16)) = 0: c(16) = 0
160 b(c(6)) = 0: c(6) = 0
60  b(c(20)) = 0: c(20) = 0
200 Next j20
    
    b(c(12)) = 0: c(12) = 0
120 b(c(14)) = 0: c(14) = 0
140 b(c(4)) = 0: c(4) = 0
40  b(c(5)) = 0: c(5) = 0
50  b(c(21)) = 0: c(21) = 0
210 b(c(22)) = 0: c(22) = 0
220 Next j22

    b(c(2)) = 0: c(2) = 0
20  b(c(24)) = 0: c(24) = 0
240 Next j24

    b(c(1)) = 0: c(1) = 0
10  b(c(25)) = 0: c(25) = 0
250 Next j25

    b(c(7)) = 0: c(7) = 0
70  b(c(9)) = 0: c(9) = 0
90  b(c(11)) = 0: c(11) = 0
110 b(c(15)) = 0: c(15) = 0
150 b(c(17)) = 0: c(17) = 0
170 b(c(19)) = 0: c(19) = 0
190 Next j19

    b(c(3)) = 0: c(3) = 0
30  b(c(23)) = 0: c(23) = 0
230 Next j23

'   Not found
    Erase b, c: n10 = 0: GoTo 2000

5
    If n10 = 25 Then
        GoSub 850:
        If fl1 = 1 Then
           n9 = n9 + 1: GoSub 660   'Print results (squares)
           n10 = 0: GoTo 2000
        End If
    End If

      Next j101
      
2000  n10 = 0
      Next j200

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

End

'   Assign to a25()

750 Select Case n10

    Case 1
    a25(1) = a(1):    a25(2) = a(2):    a25(3) = a(3):    a25(4) = a(4):    a25(5) = a(5):
    a25(26) = a(6):   a25(27) = a(7):   a25(28) = a(8):   a25(29) = a(9):   a25(30) = a(10):
    a25(51) = a(11):  a25(52) = a(12):  a25(53) = a(13):  a25(54) = a(14):  a25(55) = a(15):
    a25(76) = a(16):  a25(77) = a(17):  a25(78) = a(18):  a25(79) = a(19):  a25(80) = a(20):
    a25(101) = a(21): a25(102) = a(22): a25(103) = a(23): a25(104) = a(24): a25(105) = a(25):
                    
    Case 2
    a25(6) = a(1):    a25(7) = a(2):    a25(8) = a(3):    a25(9) = a(4):    a25(10) = a(5):
    a25(31) = a(6):   a25(32) = a(7):   a25(33) = a(8):   a25(34) = a(9):   a25(35) = a(10):
    a25(56) = a(11):  a25(57) = a(12):  a25(58) = a(13):  a25(59) = a(14):  a25(60) = a(15):
    a25(81) = a(16):  a25(82) = a(17):  a25(83) = a(18):  a25(84) = a(19):  a25(85) = a(20):
    a25(106) = a(21): a25(107) = a(22): a25(108) = a(23): a25(109) = a(24): a25(110) = a(25):
                    
    Case 3
    a25(11) = a(1):   a25(12) = a(2):   a25(13) = a(3):   a25(14) = a(4):   a25(15) = a(5):
    a25(36) = a(6):   a25(37) = a(7):   a25(38) = a(8):   a25(39) = a(9):   a25(40) = a(10):
    a25(61) = a(11):  a25(62) = a(12):  a25(63) = a(13):  a25(64) = a(14):  a25(65) = a(15):
    a25(86) = a(16):  a25(87) = a(17):  a25(88) = a(18):  a25(89) = a(19):  a25(90) = a(20):
    a25(111) = a(21): a25(112) = a(22): a25(113) = a(23): a25(114) = a(24): a25(115) = a(25):
                    
    Case 4
    a25(16) = a(1):   a25(17) = a(2):   a25(18) = a(3):   a25(19) = a(4):   a25(20) = a(5):
    a25(41) = a(6):   a25(42) = a(7):   a25(43) = a(8):   a25(44) = a(9):   a25(45) = a(10):
    a25(66) = a(11):  a25(67) = a(12):  a25(68) = a(13):  a25(69) = a(14):  a25(70) = a(15):
    a25(91) = a(16):  a25(92) = a(17):  a25(93) = a(18):  a25(94) = a(19):  a25(95) = a(20):
    a25(116) = a(21): a25(117) = a(22): a25(118) = a(23): a25(119) = a(24): a25(120) = a(25):
                    
    Case 5
    a25(21) = a(1):   a25(22) = a(2):   a25(23) = a(3):   a25(24) = a(4):   a25(25) = a(5):
    a25(46) = a(6):   a25(47) = a(7):   a25(48) = a(8):   a25(49) = a(9):   a25(50) = a(10):
    a25(71) = a(11):  a25(72) = a(12):  a25(73) = a(13):  a25(74) = a(14):  a25(75) = a(15):
    a25(96) = a(16):  a25(97) = a(17):  a25(98) = a(18):  a25(99) = a(19):  a25(100) = a(20):
    a25(121) = a(21): a25(122) = a(22): a25(123) = a(23): a25(124) = a(24): a25(125) = a(25):
                    
    Case 6
    a25(126) = a(1):  a25(127) = a(2):  a25(128) = a(3):  a25(129) = a(4):  a25(130) = a(5):
    a25(151) = a(6):  a25(152) = a(7):  a25(153) = a(8):  a25(154) = a(9):  a25(155) = a(10):
    a25(176) = a(11): a25(177) = a(12): a25(178) = a(13): a25(179) = a(14): a25(180) = a(15):
    a25(201) = a(16): a25(202) = a(17): a25(203) = a(18): a25(204) = a(19): a25(205) = a(20):
    a25(226) = a(21): a25(227) = a(22): a25(228) = a(23): a25(229) = a(24): a25(230) = a(25):
                    
    Case 7
    a25(131) = a(1):  a25(132) = a(2):  a25(133) = a(3):  a25(134) = a(4):  a25(135) = a(5):
    a25(156) = a(6):  a25(157) = a(7):  a25(158) = a(8):  a25(159) = a(9):  a25(160) = a(10):
    a25(181) = a(11): a25(182) = a(12): a25(183) = a(13): a25(184) = a(14): a25(185) = a(15):
    a25(206) = a(16): a25(207) = a(17): a25(208) = a(18): a25(209) = a(19): a25(210) = a(20):
    a25(231) = a(21): a25(232) = a(22): a25(233) = a(23): a25(234) = a(24): a25(235) = a(25):
                    
    Case 8
    a25(136) = a(1):  a25(137) = a(2):  a25(138) = a(3):  a25(139) = a(4):  a25(140) = a(5):
    a25(161) = a(6):  a25(162) = a(7):  a25(163) = a(8):  a25(164) = a(9):  a25(165) = a(10):
    a25(186) = a(11): a25(187) = a(12): a25(188) = a(13): a25(189) = a(14): a25(190) = a(15):
    a25(211) = a(16): a25(212) = a(17): a25(213) = a(18): a25(214) = a(19): a25(215) = a(20):
    a25(236) = a(21): a25(237) = a(22): a25(238) = a(23): a25(239) = a(24): a25(240) = a(25):
                    
    Case 9
    a25(141) = a(1):  a25(142) = a(2):  a25(143) = a(3):  a25(144) = a(4):  a25(145) = a(5):
    a25(166) = a(6):  a25(167) = a(7):  a25(168) = a(8):  a25(169) = a(9):  a25(170) = a(10):
    a25(191) = a(11): a25(192) = a(12): a25(193) = a(13): a25(194) = a(14): a25(195) = a(15):
    a25(216) = a(16): a25(217) = a(17): a25(218) = a(18): a25(219) = a(19): a25(220) = a(20):
    a25(241) = a(21): a25(242) = a(22): a25(243) = a(23): a25(244) = a(24): a25(245) = a(25):
            
    Case 10
    a25(146) = a(1):  a25(147) = a(2):  a25(148) = a(3):  a25(149) = a(4):  a25(150) = a(5):
    a25(171) = a(6):  a25(172) = a(7):  a25(173) = a(8):  a25(174) = a(9):  a25(175) = a(10):
    a25(196) = a(11): a25(197) = a(12): a25(198) = a(13): a25(199) = a(14): a25(200) = a(15):
    a25(221) = a(16): a25(222) = a(17): a25(223) = a(18): a25(224) = a(19): a25(225) = a(20):
    a25(246) = a(21): a25(247) = a(22): a25(248) = a(23): a25(249) = a(24): a25(250) = a(25):
                    
    Case 11
    a25(251) = a(1): a25(252) = a(2): a25(253) = a(3): a25(254) = a(4): a25(255) = a(5):
    a25(276) = a(6): a25(277) = a(7): a25(278) = a(8): a25(279) = a(9): a25(280) = a(10):
    a25(301) = a(11): a25(302) = a(12): a25(303) = a(13): a25(304) = a(14): a25(305) = a(15):
    a25(326) = a(16): a25(327) = a(17): a25(328) = a(18): a25(329) = a(19): a25(330) = a(20):
    a25(351) = a(21): a25(352) = a(22): a25(353) = a(23): a25(354) = a(24): a25(355) = a(25):
                    
    Case 12
    a25(256) = a(1):  a25(257) = a(2):  a25(258) = a(3):  a25(259) = a(4):  a25(260) = a(5):
    a25(281) = a(6):  a25(282) = a(7):  a25(283) = a(8):  a25(284) = a(9):  a25(285) = a(10):
    a25(306) = a(11): a25(307) = a(12): a25(308) = a(13): a25(309) = a(14): a25(310) = a(15):
    a25(331) = a(16): a25(332) = a(17): a25(333) = a(18): a25(334) = a(19): a25(335) = a(20):
    a25(356) = a(21): a25(357) = a(22): a25(358) = a(23): a25(359) = a(24): a25(360) = a(25):
                    
    Case 13
    a25(261) = a(1):  a25(262) = a(2):  a25(263) = a(3):  a25(264) = a(4):  a25(265) = a(5):
    a25(286) = a(6):  a25(287) = a(7):  a25(288) = a(8):  a25(289) = a(9):  a25(290) = a(10):
    a25(311) = a(11): a25(312) = a(12): a25(313) = a(13): a25(314) = a(14): a25(315) = a(15):
    a25(336) = a(16): a25(337) = a(17): a25(338) = a(18): a25(339) = a(19): a25(340) = a(20):
    a25(361) = a(21): a25(362) = a(22): a25(363) = a(23): a25(364) = a(24): a25(365) = a(25):
                    
    Case 14
    a25(266) = a(1):  a25(267) = a(2):  a25(268) = a(3):  a25(269) = a(4):  a25(270) = a(5):
    a25(291) = a(6):  a25(292) = a(7):  a25(293) = a(8):  a25(294) = a(9):  a25(295) = a(10):
    a25(316) = a(11): a25(317) = a(12): a25(318) = a(13): a25(319) = a(14): a25(320) = a(15):
    a25(341) = a(16): a25(342) = a(17): a25(343) = a(18): a25(344) = a(19): a25(345) = a(20):
    a25(366) = a(21): a25(367) = a(22): a25(368) = a(23): a25(369) = a(24): a25(370) = a(25):
            
    Case 15
    a25(271) = a(1): a25(272) = a(2): a25(273) = a(3): a25(274) = a(4): a25(275) = a(5):
    a25(296) = a(6): a25(297) = a(7): a25(298) = a(8): a25(299) = a(9): a25(300) = a(10):
    a25(321) = a(11): a25(322) = a(12): a25(323) = a(13): a25(324) = a(14): a25(325) = a(15):
    a25(346) = a(16): a25(347) = a(17): a25(348) = a(18): a25(349) = a(19): a25(350) = a(20):
    a25(371) = a(21): a25(372) = a(22): a25(373) = a(23): a25(374) = a(24): a25(375) = a(25):
                    
    Case 16
    a25(376) = a(1):  a25(377) = a(2):  a25(378) = a(3):  a25(379) = a(4):  a25(380) = a(5):
    a25(401) = a(6):  a25(402) = a(7):  a25(403) = a(8):  a25(404) = a(9):  a25(405) = a(10):
    a25(426) = a(11): a25(427) = a(12): a25(428) = a(13): a25(429) = a(14): a25(430) = a(15):
    a25(451) = a(16): a25(452) = a(17): a25(453) = a(18): a25(454) = a(19): a25(455) = a(20):
    a25(476) = a(21): a25(477) = a(22): a25(478) = a(23): a25(479) = a(24): a25(480) = a(25):
        
    Case 17
    a25(381) = a(1):  a25(382) = a(2):  a25(383) = a(3):  a25(384) = a(4):  a25(385) = a(5):
    a25(406) = a(6):  a25(407) = a(7):  a25(408) = a(8):  a25(409) = a(9):  a25(410) = a(10):
    a25(431) = a(11): a25(432) = a(12): a25(433) = a(13): a25(434) = a(14): a25(435) = a(15):
    a25(456) = a(16): a25(457) = a(17): a25(458) = a(18): a25(459) = a(19): a25(460) = a(20):
    a25(481) = a(21): a25(482) = a(22): a25(483) = a(23): a25(484) = a(24): a25(485) = a(25):
                    
    Case 18
    a25(386) = a(1):  a25(387) = a(2):  a25(388) = a(3):  a25(389) = a(4):  a25(390) = a(5):
    a25(411) = a(6):  a25(412) = a(7):  a25(413) = a(8):  a25(414) = a(9):  a25(415) = a(10):
    a25(436) = a(11): a25(437) = a(12): a25(438) = a(13): a25(439) = a(14): a25(440) = a(15):
    a25(461) = a(16): a25(462) = a(17): a25(463) = a(18): a25(464) = a(19): a25(465) = a(20):
    a25(486) = a(21): a25(487) = a(22): a25(488) = a(23): a25(489) = a(24): a25(490) = a(25):
                    
    Case 19
    a25(391) = a(1):  a25(392) = a(2):  a25(393) = a(3):  a25(394) = a(4):  a25(395) = a(5):
    a25(416) = a(6):  a25(417) = a(7):  a25(418) = a(8):  a25(419) = a(9):  a25(420) = a(10):
    a25(441) = a(11): a25(442) = a(12): a25(443) = a(13): a25(444) = a(14): a25(445) = a(15):
    a25(466) = a(16): a25(467) = a(17): a25(468) = a(18): a25(469) = a(19): a25(470) = a(20):
    a25(491) = a(21): a25(492) = a(22): a25(493) = a(23): a25(494) = a(24): a25(495) = a(25):
            
    Case 20
    a25(396) = a(1):  a25(397) = a(2):  a25(398) = a(3):  a25(399) = a(4):  a25(400) = a(5):
    a25(421) = a(6):  a25(422) = a(7):  a25(423) = a(8):  a25(424) = a(9):  a25(425) = a(10):
    a25(446) = a(11): a25(447) = a(12): a25(448) = a(13): a25(449) = a(14): a25(450) = a(15):
    a25(471) = a(16): a25(472) = a(17): a25(473) = a(18): a25(474) = a(19): a25(475) = a(20):
    a25(496) = a(21): a25(497) = a(22): a25(498) = a(23): a25(499) = a(24): a25(500) = a(25):
                    
    Case 21
    a25(501) = a(1):  a25(502) = a(2):  a25(503) = a(3):  a25(504) = a(4):  a25(505) = a(5):
    a25(526) = a(6):  a25(527) = a(7):  a25(528) = a(8):  a25(529) = a(9):  a25(530) = a(10):
    a25(551) = a(11): a25(552) = a(12): a25(553) = a(13): a25(554) = a(14): a25(555) = a(15):
    a25(576) = a(16): a25(577) = a(17): a25(578) = a(18): a25(579) = a(19): a25(580) = a(20):
    a25(601) = a(21): a25(602) = a(22): a25(603) = a(23): a25(604) = a(24): a25(605) = a(25):
                    
    Case 22
    a25(506) = a(1):  a25(507) = a(2):  a25(508) = a(3):  a25(509) = a(4):  a25(510) = a(5):
    a25(531) = a(6):  a25(532) = a(7):  a25(533) = a(8):  a25(534) = a(9):  a25(535) = a(10):
    a25(556) = a(11): a25(557) = a(12): a25(558) = a(13): a25(559) = a(14): a25(560) = a(15):
    a25(581) = a(16): a25(582) = a(17): a25(583) = a(18): a25(584) = a(19): a25(585) = a(20):
    a25(606) = a(21): a25(607) = a(22): a25(608) = a(23): a25(609) = a(24): a25(610) = a(25):
                    
    Case 23
    a25(511) = a(1):  a25(512) = a(2):  a25(513) = a(3):  a25(514) = a(4):  a25(515) = a(5):
    a25(536) = a(6):  a25(537) = a(7):  a25(538) = a(8):  a25(539) = a(9):  a25(540) = a(10):
    a25(561) = a(11): a25(562) = a(12): a25(563) = a(13): a25(564) = a(14): a25(565) = a(15):
    a25(586) = a(16): a25(587) = a(17): a25(588) = a(18): a25(589) = a(19): a25(590) = a(20):
    a25(611) = a(21): a25(612) = a(22): a25(613) = a(23): a25(614) = a(24): a25(615) = a(25):
                    
    Case 24
    a25(516) = a(1):  a25(517) = a(2):  a25(518) = a(3):  a25(519) = a(4):  a25(520) = a(5):
    a25(541) = a(6):  a25(542) = a(7):  a25(543) = a(8):  a25(544) = a(9):  a25(545) = a(10):
    a25(566) = a(11): a25(567) = a(12): a25(568) = a(13): a25(569) = a(14): a25(570) = a(15):
    a25(591) = a(16): a25(592) = a(17): a25(593) = a(18): a25(594) = a(19): a25(595) = a(20):
    a25(616) = a(21): a25(617) = a(22): a25(618) = a(23): a25(619) = a(24): a25(620) = a(25):
            
    Case 25
    a25(521) = a(1):  a25(522) = a(2):  a25(523) = a(3):  a25(524) = a(4):  a25(525) = a(5):
    a25(546) = a(6):  a25(547) = a(7):  a25(548) = a(8):  a25(549) = a(9):  a25(550) = a(10):
    a25(571) = a(11): a25(572) = a(12): a25(573) = a(13): a25(574) = a(14): a25(575) = a(15):
    a25(596) = a(16): a25(597) = a(17): a25(598) = a(18): a25(599) = a(19): a25(600) = a(20):
    a25(621) = a(21): a25(622) = a(22): a25(623) = a(23): a25(624) = a(24): a25(625) = a(25):

    End Select
    Return

'   Print results: squares a15()

660 n1 = n1 + 1
    If n1 = 2 Then
        n1 = 1: k1 = k1 + 26: k2 = 1
    Else
        If n9 > 1 Then k2 = k2 + 26
    End If
    
    Cells(k1, k2 + 1).Select
    Cells(k1, k2 + 1).Font.Color = -4165632
    Cells(k1, k2 + 1).Value = s25
    
    i3 = 0
    For i1 = 1 To 25
        For i2 = 1 To 25
            i3 = i3 + 1
            Cells(k1 + i1, k2 + i2).Value = a25(i3)
        Next i2
    Next i1
    Return

'   Exclude solutions with identical numbers a()

800 fl1 = 1
    For j1 = 1 To 25
       a2 = a(j1)
       For j2 = (1 + j1) To 25
           If a2 = a(j2) Then fl1 = 0: Return
       Next j2
    Next j1
    Return

'   Exclude solutions with identical numbers a25()

850 fl1 = 1
    For j1 = 1 To 625
       a2 = a25(j1): If a2 = 0 Then GoTo 860
       For j2 = (1 + j1) To 625
           If a2 = a25(j2) Then fl1 = 0: Return
       Next j2
860 Next j1
    Return

End Sub

Vorige Pagina About the Author