answersLogoWhite

0

You have to create 9 empty labels on the gui, then randomize 9#'s. assign each random number to the labels in the 3x3 square. ( you have to keep in your head where each random number will be). Then create a loop that does not end until each row, (labels 1-3), each column (labels 1,4,7), and diagnal ( 1,5,9) are different unique numbers and they add to 15(or the magic number).

-----------

For magic squares with an odd number of rows/columns (i.e. 3x3, 5x5, etc.), there is a simple algorithm to fill the squares. Magic squares with even number of rows/columns do NOT follow this algorithm.

Start in the top row, middle square. Place the number 1 there. The rest of the squares are filled as follows.

Choose the next cell by moving up and to the right. If the square falls outside the squares, the next number goes in the first cell of the row above it. If there is no row above it, drop down to the bottom of the next column and place the number there. If there is no column to the right, drop immediately below and place the number there. If the cell is already filled, drop immediately below and place the number there. Continue until all cells are filled. The number in the middle of the sequence should fall in the middle column of the middle row. The formula for the total of each row/column is: total = n * ((( n * n ) / 2 ) + 0.5)

Samples:

Magic square of 3x3:

8 1 6

3 5 7

4 9 2

Each row/column adds up to: 3 * ((( 3 * 3 ) / 2 ) + 0.5) = 15

-----------------------

Magic square of 5x5:

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

Each row/column adds up to: 5 * ((( 5 * 5 ) / 2 ) + 0.5 ) = 65

This algorithm will work for ALL magic squares with an odd number of rows/columns (where number of rows is the same as the number of columns).

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

How do you fly using magic spells?

You can't fly with magic spells as there is no such thing as magic. If you want to fly, then you best option is to learn hang gliding or get a pilot's license.


In LittleBigPlanet PSP how do you place a Magic Mouth on a story character in a created level?

just like anything else! just press x when the magic mouth is where you want it. then press square to tweak it and you got it from there.


How do you make shortcuts for magic in kingdom hearts 2?

When you press start, there's is a menu, and there is a place where you can customize items and magic. There you can choose 4 types of magic that you want as "ex", "square", "triangle" and "circle". After you do that, while outside of the menu, you press L1 and any one of these buttons and it will do the magic you chose it to be.


You want C program on students information record using file handling?

yes sir


How can a 1GB program run in only 512MB of memory?

Through the magic of Virtual Memory, though it might page to disk more often than you want.


How do you write a program using 57252077?

Please be more explicit, 57252077 is a bit of a mystery. Do you want a program that uses the number 57252077 in some way?


Who can teach me magic?

It depends on what type of magic you want to learn.


How do I send money using Square Cash?

To send money using Square Cash, you can open the app, enter the amount you want to send, select a recipient from your contacts, and then confirm the transaction.


How do you use Lunar Magic?

i want to use lunar magic but i have no idea how!!!!!!


How do you say 'all i want is my magic' in German?

all i want is my magic = Alles was ich will ist meine Magie


Is it good to learn magic?

It is not bad to learn Magic. But ask yourself why you want to learn Magic. It is not easy...


How do you be magic?

If you want to be magic you have to sit down for a very long time and hum