One set answer of magic square matrix
曾慶潭 Ching-Tang Tseng
ilikeforth@gmail.com
Hamilton, New Zealand
2 June 2018
兩千六百年前,中國的信史記載,古人這樣表示、研究、應用魔術方陣。
兩千六百年後的今天,中國人這樣子表示、研究、應用魔術方陣。
\ magic square matrics generator
\ Author: Ching-Tang Tseng
\ 20150528, Hamilton, New Zealand
\ ******************************
\ (1).Data structure declared heap
\ Attention! max is a reserved word of mathematical function.
10 integers x y l n q sqd2 q2 nr maxx msum
100 100 (matrix) sq
\ ***********************************
\ (2).Data input heap
: 4n+2init
basic
\ 10 let n = 6
20 let msum = n * ( n ** 2 + 1 ) / 2
30 let sqd2 = n / 2 :: q2 = sqd2 ** 2
40 let l = ( n - 2 ) / 4
50 let x = sqd2 / 2 + 1 :: y = 1
60 let nr = 1
70 end ;
: 2n+1init
basic
\ 10 let n = 7
20 let nr = 1
30 let x = n - ( n / 2 )
40 let y = 1
50 let msum = n * ( n ** 2 + 1 ) / 2
50 let maxx = n * n
60 end ;
: 4ninit
basic
\ 10 let n = 8
20 let msum = n * ( n ** 2 + 1 ) / 2
30 let q = n / 4
40 let nr = 1
50 end ;
\ ********************************
\ (3).Auxiliary instructions heap
: check-columms-and-rows
basic
10 For y = 1 To n
20 let nr = 0 :: q = 0
30 For x = 1 To n
40 let nr = nr + sq ( x y )
50 let q = q + sq ( y x )
60 Next x
70 If nr <> msum Or q <> msum Then 90
80 goto 100
90 run cr x 4 .r y 4 .r cr -1 abort" Error1: value <> magic sum " cr
100 Next y
110 end ;
: check-diagonals
basic
10 let nr = 0 :: q = 0
20 For x = 1 To n
30 let nr = nr + sq ( x x )
40 let q = q + sq ( x ( n - x + 1 ) )
50 Next x
60 If nr <> msum Or q <> msum Then 80
70 goto 90
80 run cr nr . 3 spaces q . 3 spaces cr -1 abort" Error2: value <> magic sum " cr
90 end ;
: EraseSq
basic
10 for y = 1 to 100
20 for x = 1 to 100
30 let sq ( x y ) = 0
40 next x
50 next y
60 end ;
: PrintSq
basic
10 Print " Magic square size : " ; n ; " * " ; n
20 Print " The magic sum = " ; msum
30 run cr
40 For y = 1 To n
50 For x = 1 To n
60 let q = sq ( x y )
70 run q 4 .R
80 Next x
90 run cr
100 Next y
110 end ;
\ *******************************
\ (4).Main code heap
: 2n+1
basic
10 if sq ( x y ) = 0 then 30
20 goto 100
30 let sq ( x y ) = nr
40 if nr mod n = 0 then 70
50 let x = x + 1
55 let y = y - 1
60 goto 80
70 let y = y + 1
80 let nr = nr + 1
100 if x > n then 120
110 goto 200
120 let x = 1
130 if sq ( x y ) <> 0 then 150
140 goto 200
150 let x = x + 1
200 if y < 1 then 220
210 goto 300
220 let y = n
230 if sq ( x y ) <> 0 then 250
240 goto 300
250 let y = y - 1
300 if nr > maxx then 400
310 goto -10
400 end ;
: 4n
basic
10 for y = 1 to n
20 for x = q + 1 to n - q
30 let sq ( x y ) = 1
40 next x
50 next y
60 For x = 1 To n
70 For y = q + 1 To n - q
80 let sq ( x y ) = sq ( x y ) xor 1
90 Next y
100 Next x
110 let q = n * n + 1
120 for y = 1 To n
130 for x = 1 To n
140 if sq ( x y ) = 0 Then 170
150 let sq ( x y ) = nr
160 goto 180
170 let sq ( x y ) = q - nr
180 let nr = nr + 1
190 Next x
200 Next y
210 end ;
\ Attention! in ABC FORTH, index can not be an algebraic expression
: x+sqd2 x sqd2 + ;
: y+sqd2 y sqd2 + ;
: l+1 l 1+ ;
: 4n+2
basic
10 if sq ( x y ) = 0 then 30
20 goto 130
30 let sq ( x y ) = nr
40 let sq ( x+sqd2 y+sqd2 ) = nr + q2
50 let sq ( x+sqd2 y ) = nr + q2 * 2
60 let sq ( x y+sqd2 ) = nr + q2 * 3
70 if nr mod sqd2 = 0 then 90
80 goto 110
90 let y = y + 1
100 goto 120
110 let x = x + 1 :: y = y - 1
120 let nr = nr + 1
130 if x > sqd2 then 150
140 goto 200
150 let x = 1
160 if sq ( x y ) <> 0 then 180
170 goto 200
180 let x = x + 1
200 if y < 1 then 220
210 goto 260
220 let y = sqd2
230 if sq ( x y ) <> 0 then 250
240 goto 260
250 let y = y - 1
260 if nr > q2 then 300
270 goto -10
300 for y = 1 to sqd2
310 for x = 1 to l
320 let q = sq ( x y )
330 let sq ( x y ) = sq ( x y+sqd2 )
340 let sq ( x y+sqd2 ) = q
350 next x
360 next y
400 let y = ( sqd2 / 2 ) + 1
410 let q = sq ( 1 y )
420 let sq ( 1 y ) = sq ( 1 y+sqd2 )
430 let sq ( 1 y+sqd2 ) = q
440 let q = sq ( l+1 y )
450 let sq ( l+1 y ) = sq ( l+1 y+sqd2 )
460 let sq ( l+1 y+sqd2 ) = q
500 for y = 1 to sqd2
510 for x = n - l + 2 to n
520 let q = sq ( x y )
530 let sq ( x y ) = sq ( x y+sqd2 )
540 let sq ( x y+sqd2 ) = q
550 next x
560 next y
1000 end ;
\ **********************
\ (5).Manipulation heap
: magics ( n -- )
[[ n ]] !
EraseSq
basic
10 if n mod 2 = 1 then 100
20 if n mod 4 = 2 then 200
30 goto 300
100 run 2n+1Init
110 run 2n+1
120 goto 400
200 run 4n+2Init
210 run 4n+2
220 goto 400
300 run 4nInit
310 run 4n
400 run PrintSq
500 run check-columms-and-rows
510 run check-diagonals
1000 end ;
: main ( -- )
21 3
do i magics loop ;
main
\ ********** the end ***************
執行結果:
\ Author: Ching-Tang Tseng
\ 20150528, Hamilton, New Zealand
\ ******************************
\ (1).Data structure declared heap
\ Attention! max is a reserved word of mathematical function.
10 integers x y l n q sqd2 q2 nr maxx msum
100 100 (matrix) sq
\ ***********************************
\ (2).Data input heap
: 4n+2init
basic
\ 10 let n = 6
20 let msum = n * ( n ** 2 + 1 ) / 2
30 let sqd2 = n / 2 :: q2 = sqd2 ** 2
40 let l = ( n - 2 ) / 4
50 let x = sqd2 / 2 + 1 :: y = 1
60 let nr = 1
70 end ;
: 2n+1init
basic
\ 10 let n = 7
20 let nr = 1
30 let x = n - ( n / 2 )
40 let y = 1
50 let msum = n * ( n ** 2 + 1 ) / 2
50 let maxx = n * n
60 end ;
: 4ninit
basic
\ 10 let n = 8
20 let msum = n * ( n ** 2 + 1 ) / 2
30 let q = n / 4
40 let nr = 1
50 end ;
\ ********************************
\ (3).Auxiliary instructions heap
: check-columms-and-rows
basic
10 For y = 1 To n
20 let nr = 0 :: q = 0
30 For x = 1 To n
40 let nr = nr + sq ( x y )
50 let q = q + sq ( y x )
60 Next x
70 If nr <> msum Or q <> msum Then 90
80 goto 100
90 run cr x 4 .r y 4 .r cr -1 abort" Error1: value <> magic sum " cr
100 Next y
110 end ;
: check-diagonals
basic
10 let nr = 0 :: q = 0
20 For x = 1 To n
30 let nr = nr + sq ( x x )
40 let q = q + sq ( x ( n - x + 1 ) )
50 Next x
60 If nr <> msum Or q <> msum Then 80
70 goto 90
80 run cr nr . 3 spaces q . 3 spaces cr -1 abort" Error2: value <> magic sum " cr
90 end ;
: EraseSq
basic
10 for y = 1 to 100
20 for x = 1 to 100
30 let sq ( x y ) = 0
40 next x
50 next y
60 end ;
: PrintSq
basic
10 Print " Magic square size : " ; n ; " * " ; n
20 Print " The magic sum = " ; msum
30 run cr
40 For y = 1 To n
50 For x = 1 To n
60 let q = sq ( x y )
70 run q 4 .R
80 Next x
90 run cr
100 Next y
110 end ;
\ *******************************
\ (4).Main code heap
: 2n+1
basic
10 if sq ( x y ) = 0 then 30
20 goto 100
30 let sq ( x y ) = nr
40 if nr mod n = 0 then 70
50 let x = x + 1
55 let y = y - 1
60 goto 80
70 let y = y + 1
80 let nr = nr + 1
100 if x > n then 120
110 goto 200
120 let x = 1
130 if sq ( x y ) <> 0 then 150
140 goto 200
150 let x = x + 1
200 if y < 1 then 220
210 goto 300
220 let y = n
230 if sq ( x y ) <> 0 then 250
240 goto 300
250 let y = y - 1
300 if nr > maxx then 400
310 goto -10
400 end ;
: 4n
basic
10 for y = 1 to n
20 for x = q + 1 to n - q
30 let sq ( x y ) = 1
40 next x
50 next y
60 For x = 1 To n
70 For y = q + 1 To n - q
80 let sq ( x y ) = sq ( x y ) xor 1
90 Next y
100 Next x
110 let q = n * n + 1
120 for y = 1 To n
130 for x = 1 To n
140 if sq ( x y ) = 0 Then 170
150 let sq ( x y ) = nr
160 goto 180
170 let sq ( x y ) = q - nr
180 let nr = nr + 1
190 Next x
200 Next y
210 end ;
\ Attention! in ABC FORTH, index can not be an algebraic expression
: x+sqd2 x sqd2 + ;
: y+sqd2 y sqd2 + ;
: l+1 l 1+ ;
: 4n+2
basic
10 if sq ( x y ) = 0 then 30
20 goto 130
30 let sq ( x y ) = nr
40 let sq ( x+sqd2 y+sqd2 ) = nr + q2
50 let sq ( x+sqd2 y ) = nr + q2 * 2
60 let sq ( x y+sqd2 ) = nr + q2 * 3
70 if nr mod sqd2 = 0 then 90
80 goto 110
90 let y = y + 1
100 goto 120
110 let x = x + 1 :: y = y - 1
120 let nr = nr + 1
130 if x > sqd2 then 150
140 goto 200
150 let x = 1
160 if sq ( x y ) <> 0 then 180
170 goto 200
180 let x = x + 1
200 if y < 1 then 220
210 goto 260
220 let y = sqd2
230 if sq ( x y ) <> 0 then 250
240 goto 260
250 let y = y - 1
260 if nr > q2 then 300
270 goto -10
300 for y = 1 to sqd2
310 for x = 1 to l
320 let q = sq ( x y )
330 let sq ( x y ) = sq ( x y+sqd2 )
340 let sq ( x y+sqd2 ) = q
350 next x
360 next y
400 let y = ( sqd2 / 2 ) + 1
410 let q = sq ( 1 y )
420 let sq ( 1 y ) = sq ( 1 y+sqd2 )
430 let sq ( 1 y+sqd2 ) = q
440 let q = sq ( l+1 y )
450 let sq ( l+1 y ) = sq ( l+1 y+sqd2 )
460 let sq ( l+1 y+sqd2 ) = q
500 for y = 1 to sqd2
510 for x = n - l + 2 to n
520 let q = sq ( x y )
530 let sq ( x y ) = sq ( x y+sqd2 )
540 let sq ( x y+sqd2 ) = q
550 next x
560 next y
1000 end ;
\ **********************
\ (5).Manipulation heap
: magics ( n -- )
[[ n ]] !
EraseSq
basic
10 if n mod 2 = 1 then 100
20 if n mod 4 = 2 then 200
30 goto 300
100 run 2n+1Init
110 run 2n+1
120 goto 400
200 run 4n+2Init
210 run 4n+2
220 goto 400
300 run 4nInit
310 run 4n
400 run PrintSq
500 run check-columms-and-rows
510 run check-diagonals
1000 end ;
: main ( -- )
21 3
do i magics loop ;
main
\ ********** the end ***************
執行結果:
ching@ctt:~$ ./l AMDX86 ciforth 5.3.0 fload magic.f OK main Magic square size : 3 * 3 The magic sum = 15 8 1 6 3 5 7 4 9 2 Magic square size : 4 * 4 The magic sum = 34 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1 Magic square size : 5 * 5 The magic sum = 65 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 Magic square size : 6 * 6 The magic sum = 111 35 1 6 26 19 24 3 32 7 21 23 25 31 9 2 22 27 20 8 28 33 17 10 15 30 5 34 12 14 16 4 36 29 13 18 11 Magic square size : 7 * 7 The magic sum = 175 30 39 48 1 10 19 28 38 47 7 9 18 27 29 46 6 8 17 26 35 37 5 14 16 25 34 36 45 13 15 24 33 42 44 4 21 23 32 41 43 3 12 22 31 40 49 2 11 20 Magic square size : 8 * 8 The magic sum = 260 64 63 3 4 5 6 58 57 56 55 11 12 13 14 50 49 17 18 46 45 44 43 23 24 25 26 38 37 36 35 31 32 33 34 30 29 28 27 39 40 41 42 22 21 20 19 47 48 16 15 51 52 53 54 10 9 8 7 59 60 61 62 2 1 Magic square size : 9 * 9 The magic sum = 369 47 58 69 80 1 12 23 34 45 57 68 79 9 11 22 33 44 46 67 78 8 10 21 32 43 54 56 77 7 18 20 31 42 53 55 66 6 17 19 30 41 52 63 65 76 16 27 29 40 51 62 64 75 5 26 28 39 50 61 72 74 4 15 36 38 49 60 71 73 3 14 25 37 48 59 70 81 2 13 24 35 Magic square size : 10 * 10 The magic sum = 505 92 99 1 8 15 67 74 51 58 40 98 80 7 14 16 73 55 57 64 41 4 81 88 20 22 54 56 63 70 47 85 87 19 21 3 60 62 69 71 28 86 93 25 2 9 61 68 75 52 34 17 24 76 83 90 42 49 26 33 65 23 5 82 89 91 48 30 32 39 66 79 6 13 95 97 29 31 38 45 72 10 12 94 96 78 35 37 44 46 53 11 18 100 77 84 36 43 50 27 59 Magic square size : 11 * 11 The magic sum = 671 68 81 94 107 120 1 14 27 40 53 66 80 93 106 119 11 13 26 39 52 65 67 92 105 118 10 12 25 38 51 64 77 79 104 117 9 22 24 37 50 63 76 78 91 116 8 21 23 36 49 62 75 88 90 103 7 20 33 35 48 61 74 87 89 102 115 19 32 34 47 60 73 86 99 101 114 6 31 44 46 59 72 85 98 100 113 5 18 43 45 58 71 84 97 110 112 4 17 30 55 57 70 83 96 109 111 3 16 29 42 56 69 82 95 108 121 2 15 28 41 54 Magic square size : 12 * 12 The magic sum = 870 144 143 142 4 5 6 7 8 9 135 134 133 132 131 130 16 17 18 19 20 21 123 122 121 120 119 118 28 29 30 31 32 33 111 110 109 37 38 39 105 104 103 102 101 100 46 47 48 49 50 51 93 92 91 90 89 88 58 59 60 61 62 63 81 80 79 78 77 76 70 71 72 73 74 75 69 68 67 66 65 64 82 83 84 85 86 87 57 56 55 54 53 52 94 95 96 97 98 99 45 44 43 42 41 40 106 107 108 36 35 34 112 113 114 115 116 117 27 26 25 24 23 22 124 125 126 127 128 129 15 14 13 12 11 10 136 137 138 139 140 141 3 2 1 Magic square size : 13 * 13 The magic sum = 1105 93 108 123 138 153 168 1 16 31 46 61 76 91 107 122 137 152 167 13 15 30 45 60 75 90 92 121 136 151 166 12 14 29 44 59 74 89 104 106 135 150 165 11 26 28 43 58 73 88 103 105 120 149 164 10 25 27 42 57 72 87 102 117 119 134 163 9 24 39 41 56 71 86 101 116 118 133 148 8 23 38 40 55 70 85 100 115 130 132 147 162 22 37 52 54 69 84 99 114 129 131 146 161 7 36 51 53 68 83 98 113 128 143 145 160 6 21 50 65 67 82 97 112 127 142 144 159 5 20 35 64 66 81 96 111 126 141 156 158 4 19 34 49 78 80 95 110 125 140 155 157 3 18 33 48 63 79 94 109 124 139 154 169 2 17 32 47 62 77 Magic square size : 14 * 14 The magic sum = 1379 177 186 195 1 10 19 28 128 137 146 99 108 68 77 185 194 154 9 18 27 29 136 145 105 107 116 76 78 193 153 155 17 26 35 37 144 104 106 115 124 84 86 5 161 163 172 34 36 45 103 112 114 123 132 85 94 160 162 171 33 42 44 4 111 113 122 131 140 93 53 168 170 179 41 43 3 12 119 121 130 139 141 52 61 169 178 187 49 2 11 20 120 129 138 147 100 60 69 30 39 48 148 157 166 175 79 88 97 50 59 117 126 38 47 7 156 165 174 176 87 96 56 58 67 125 127 46 6 8 164 173 182 184 95 55 57 66 75 133 135 152 14 16 25 181 183 192 54 63 65 74 83 134 143 13 15 24 180 189 191 151 62 64 73 82 91 142 102 21 23 32 188 190 150 159 70 72 81 90 92 101 110 22 31 40 196 149 158 167 71 80 89 98 51 109 118 Magic square size : 15 * 15 The magic sum = 1695 122 139 156 173 190 207 224 1 18 35 52 69 86 103 120 138 155 172 189 206 223 15 17 34 51 68 85 102 119 121 154 171 188 205 222 14 16 33 50 67 84 101 118 135 137 170 187 204 221 13 30 32 49 66 83 100 117 134 136 153 186 203 220 12 29 31 48 65 82 99 116 133 150 152 169 202 219 11 28 45 47 64 81 98 115 132 149 151 168 185 218 10 27 44 46 63 80 97 114 131 148 165 167 184 201 9 26 43 60 62 79 96 113 130 147 164 166 183 200 217 25 42 59 61 78 95 112 129 146 163 180 182 199 216 8 41 58 75 77 94 111 128 145 162 179 181 198 215 7 24 57 74 76 93 110 127 144 161 178 195 197 214 6 23 40 73 90 92 109 126 143 160 177 194 196 213 5 22 39 56 89 91 108 125 142 159 176 193 210 212 4 21 38 55 72 105 107 124 141 158 175 192 209 211 3 20 37 54 71 88 106 123 140 157 174 191 208 225 2 19 36 53 70 87 104 Magic square size : 16 * 16 The magic sum = 2056 256 255 254 253 5 6 7 8 9 10 11 12 244 243 242 241 240 239 238 237 21 22 23 24 25 26 27 28 228 227 226 225 224 223 222 221 37 38 39 40 41 42 43 44 212 211 210 209 208 207 206 205 53 54 55 56 57 58 59 60 196 195 194 193 65 66 67 68 188 187 186 185 184 183 182 181 77 78 79 80 81 82 83 84 172 171 170 169 168 167 166 165 93 94 95 96 97 98 99 100 156 155 154 153 152 151 150 149 109 110 111 112 113 114 115 116 140 139 138 137 136 135 134 133 125 126 127 128 129 130 131 132 124 123 122 121 120 119 118 117 141 142 143 144 145 146 147 148 108 107 106 105 104 103 102 101 157 158 159 160 161 162 163 164 92 91 90 89 88 87 86 85 173 174 175 176 177 178 179 180 76 75 74 73 72 71 70 69 189 190 191 192 64 63 62 61 197 198 199 200 201 202 203 204 52 51 50 49 48 47 46 45 213 214 215 216 217 218 219 220 36 35 34 33 32 31 30 29 229 230 231 232 233 234 235 236 20 19 18 17 16 15 14 13 245 246 247 248 249 250 251 252 4 3 2 1 Magic square size : 17 * 17 The magic sum = 2465 155 174 193 212 231 250 269 288 1 20 39 58 77 96 115 134 153 173 192 211 230 249 268 287 17 19 38 57 76 95 114 133 152 154 191 210 229 248 267 286 16 18 37 56 75 94 113 132 151 170 172 209 228 247 266 285 15 34 36 55 74 93 112 131 150 169 171 190 227 246 265 284 14 33 35 54 73 92 111 130 149 168 187 189 208 245 264 283 13 32 51 53 72 91 110 129 148 167 186 188 207 226 263 282 12 31 50 52 71 90 109 128 147 166 185 204 206 225 244 281 11 30 49 68 70 89 108 127 146 165 184 203 205 224 243 262 10 29 48 67 69 88 107 126 145 164 183 202 221 223 242 261 280 28 47 66 85 87 106 125 144 163 182 201 220 222 241 260 279 9 46 65 84 86 105 124 143 162 181 200 219 238 240 259 278 8 27 64 83 102 104 123 142 161 180 199 218 237 239 258 277 7 26 45 82 101 103 122 141 160 179 198 217 236 255 257 276 6 25 44 63 100 119 121 140 159 178 197 216 235 254 256 275 5 24 43 62 81 118 120 139 158 177 196 215 234 253 272 274 4 23 42 61 80 99 136 138 157 176 195 214 233 252 271 273 3 22 41 60 79 98 117 137 156 175 194 213 232 251 270 289 2 21 40 59 78 97 116 135 Magic square size : 18 * 18 The magic sum = 2925 290 301 312 323 1 12 23 34 45 209 220 231 242 163 174 104 115 126 300 311 322 252 11 22 33 44 46 219 230 241 171 173 184 114 125 127 310 321 251 253 21 32 43 54 56 229 240 170 172 183 194 124 135 137 320 250 261 263 31 42 53 55 66 239 169 180 182 193 204 134 136 147 6 260 262 273 284 52 63 65 76 168 179 181 192 203 214 144 146 157 259 270 272 283 51 62 64 75 5 178 189 191 202 213 224 145 156 86 269 271 282 293 61 72 74 4 15 188 190 201 212 223 234 155 85 96 279 281 292 303 71 73 3 14 25 198 200 211 222 233 235 84 95 106 280 291 302 313 81 2 13 24 35 199 210 221 232 243 164 94 105 116 47 58 69 80 244 255 266 277 288 128 139 150 161 82 93 185 196 207 57 68 79 9 254 265 276 287 289 138 149 160 90 92 103 195 206 208 67 78 8 10 264 275 286 297 299 148 159 89 91 102 113 205 216 218 77 7 18 20 274 285 296 298 309 158 88 99 101 112 123 215 217 228 249 17 19 30 41 295 306 308 319 87 98 100 111 122 133 225 227 238 16 27 29 40 294 305 307 318 248 97 108 110 121 132 143 226 237 167 26 28 39 50 304 315 317 247 258 107 109 120 131 142 153 236 166 177 36 38 49 60 314 316 246 257 268 117 119 130 141 152 154 165 176 187 37 48 59 70 324 245 256 267 278 118 129 140 151 162 83 175 186 197 Magic square size : 19 * 19 The magic sum = 3439 192 213 234 255 276 297 318 339 360 1 22 43 64 85 106 127 148 169 190 212 233 254 275 296 317 338 359 19 21 42 63 84 105 126 147 168 189 191 232 253 274 295 316 337 358 18 20 41 62 83 104 125 146 167 188 209 211 252 273 294 315 336 357 17 38 40 61 82 103 124 145 166 187 208 210 231 272 293 314 335 356 16 37 39 60 81 102 123 144 165 186 207 228 230 251 292 313 334 355 15 36 57 59 80 101 122 143 164 185 206 227 229 250 271 312 333 354 14 35 56 58 79 100 121 142 163 184 205 226 247 249 270 291 332 353 13 34 55 76 78 99 120 141 162 183 204 225 246 248 269 290 311 352 12 33 54 75 77 98 119 140 161 182 203 224 245 266 268 289 310 331 11 32 53 74 95 97 118 139 160 181 202 223 244 265 267 288 309 330 351 31 52 73 94 96 117 138 159 180 201 222 243 264 285 287 308 329 350 10 51 72 93 114 116 137 158 179 200 221 242 263 284 286 307 328 349 9 30 71 92 113 115 136 157 178 199 220 241 262 283 304 306 327 348 8 29 50 91 112 133 135 156 177 198 219 240 261 282 303 305 326 347 7 28 49 70 111 132 134 155 176 197 218 239 260 281 302 323 325 346 6 27 48 69 90 131 152 154 175 196 217 238 259 280 301 322 324 345 5 26 47 68 89 110 151 153 174 195 216 237 258 279 300 321 342 344 4 25 46 67 88 109 130 171 173 194 215 236 257 278 299 320 341 343 3 24 45 66 87 108 129 150 172 193 214 235 256 277 298 319 340 361 2 23 44 65 86 107 128 149 170 Magic square size : 20 * 20 The magic sum = 4010 400 399 398 397 396 6 7 8 9 10 11 12 13 14 15 385 384 383 382 381 380 379 378 377 376 26 27 28 29 30 31 32 33 34 35 365 364 363 362 361 360 359 358 357 356 46 47 48 49 50 51 52 53 54 55 345 344 343 342 341 340 339 338 337 336 66 67 68 69 70 71 72 73 74 75 325 324 323 322 321 320 319 318 317 316 86 87 88 89 90 91 92 93 94 95 305 304 303 302 301 101 102 103 104 105 295 294 293 292 291 290 289 288 287 286 116 117 118 119 120 121 122 123 124 125 275 274 273 272 271 270 269 268 267 266 136 137 138 139 140 141 142 143 144 145 255 254 253 252 251 250 249 248 247 246 156 157 158 159 160 161 162 163 164 165 235 234 233 232 231 230 229 228 227 226 176 177 178 179 180 181 182 183 184 185 215 214 213 212 211 210 209 208 207 206 196 197 198 199 200 201 202 203 204 205 195 194 193 192 191 190 189 188 187 186 216 217 218 219 220 221 222 223 224 225 175 174 173 172 171 170 169 168 167 166 236 237 238 239 240 241 242 243 244 245 155 154 153 152 151 150 149 148 147 146 256 257 258 259 260 261 262 263 264 265 135 134 133 132 131 130 129 128 127 126 276 277 278 279 280 281 282 283 284 285 115 114 113 112 111 110 109 108 107 106 296 297 298 299 300 100 99 98 97 96 306 307 308 309 310 311 312 313 314 315 85 84 83 82 81 80 79 78 77 76 326 327 328 329 330 331 332 333 334 335 65 64 63 62 61 60 59 58 57 56 346 347 348 349 350 351 352 353 354 355 45 44 43 42 41 40 39 38 37 36 366 367 368 369 370 371 372 373 374 375 25 24 23 22 21 20 19 18 17 16 386 387 388 389 390 391 392 393 394 395 5 4 3 2 1 OK
附註 : 20241111 重新整理後貼出。
沒有留言:
張貼留言