Created
April 17, 2013 16:13
-
-
Save noeldelgado/5405571 to your computer and use it in GitHub Desktop.
Calculate the exact number of rows and columns for N number of items
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var N = 216, // total number of items | |
rows = Math.floor( Math.sqrt( N ) ), | |
columns = 0; | |
while ( N % rows != 0 ) { | |
rows = rows - 1; | |
} | |
columns = N / rows; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment