I have a # of images that I\'m stitching together into a sprite sheet, how can I calculate the number of rows and columns to fit equally in an even rectangle (no blank space
Since it's unlikely you'll have a large number to begin with there are a lot of ways you can proceed in factoring it.
See Best way to find all factors of a given number in C# for some of them.
The simplest is: - Loop from 1 to the square root of the number, call the index "i".
This will give you all the integers that divide your number N. The "other" number is, of course, obtained by dividing N by that integer.
Then, you need to pick the best pair according to some rule. You can chose the ones with the smallest difference: if a * b = N
, choose the ones with the smallest absolute value of (a-b)