CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: magic square

  1. #1
    Join Date
    Jul 2005
    Location
    Louisville, KY
    Posts
    201

    magic square

    Is there an existing formula to find the number of solutions of a magic square?

    I know:

    3x3
    4x4
    5x5
    ..
    I'd like to be able to do a nxn.

    I can also do the magic number sums.

    Any help in the right direction would be greatly appreciated.

  2. #2
    Join Date
    Jun 2006
    Posts
    437

    Re: magic square

    Hi all.

    Take a look at
    http://mathworld.wolfram.com/MagicSquare.html

    It provides some methods to build magis square nxn.

  3. #3
    Join Date
    Jul 2005
    Location
    Louisville, KY
    Posts
    201

    Re: magic square

    According to that webpage:

    The number of 6×6 squares is not known, but Pinn and Wieczerkowski (1998) estimated it to be (1.7745+/-0.0016)×10^(19) using Monte Carlo simulation and methods from statistical mechanics.

    So, I guess this project would be impossible, unless I were to sit down and figure them out myself.

  4. #4
    Join Date
    May 2002
    Posts
    1,435

    Re: magic square

    This is one of the unsolved questions in mathematics. If you do happen to find a solution you will join the ranks of great mathematicians. Keep us posted!

  5. #5
    Join Date
    Jul 2005
    Location
    Louisville, KY
    Posts
    201

    Re: magic square

    Sounds like an intriguing task.

  6. #6
    Join Date
    Jul 2005
    Location
    Louisville, KY
    Posts
    201

    Re: magic square

    Since there are so many different solutions, would it be better to make the application multi-threaded - and thread several different computations at once? or would it be better to just run it straight forward no threads?

  7. #7
    Join Date
    Apr 2004
    Posts
    102

    Re: magic square

    Whether you should multi-thread or not would depend on the hardware you are targeting.

    If you are targeting a single-core, non-hyperthreaded processor, you are going to take an extra CPU hit whenever the threads switch.

    If you are targeting a single-core, hyperthreaded processor, probably go with just 2 threads.

    If you have multiple cores/multiple processors, you can probably scale up accordingly. There are probably some additional tricks you need to do to get your program to run on more than one core. The Multithreading Forum would probably be the place to go to get further advice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured