title: Java code for arranging blocks in rectangular area
body: <p>I want to arrange blocks of equal sizes into a rectangular area like follows</p>
  
  <p><img src="https://i.stack.imgur.com/fkgtS.png" alt="enter image description here"></p>
  
  <p>So the input should be number of blocks and the output should be (n1, n2, n3...) where n1 is the number of blocks in row 1 and so on....</p>
  
  <p>For example for the above image out will be (2,3,2) for input 7. </p>
  
  <p>Is there some library to achieve this ?  The constraint i want is to arrange in lowest number of rows with each row of same width. also I want is no rows should contain more than 4 image.</p>