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
What's your priority? Do you want it to have the difference between height, width to be minimum, or anything like that?
Given the number n of images. You should take every number i from 1 to sqrt(n). If n can be divided by i (n%i ==0), divide and increment an array power[i] each time it divides. If n cannot be divided any more by i (aka n%i != 0) increment i else divide again.
You should get all the divisors and their biggest power in a given number n.
Make combinations of these and you will get the dimensions of your square.