title: Distribute points in a row using as little space as possible
body: <p>I have a row that can contain up to <code>N</code> points. I want to distribute <code>x</code> points inside that row from the center outwards, using as little space.</p>
  
  <p>I have managed to distribute points evenly within the row, but it uses all of the available space. Using the formula <code>floor((i+0.5)*N/x)</code>, I get the following result, considering <code>N=9</code>:</p>
  
  <pre><code>4 
  2 6 
  1 4 7 
  1 3 5 7 
  0 2 4 6 8 
  0 2 3 5 6 8 
  0 1 3 4 5 7 8 
  0 1 2 3 5 6 7 8 
  0 1 2 3 4 5 6 7 8
  </code></pre>
  
  <p>The following is an example graphical representation of the indeces shown in the output above:</p>
  
  <p><a href="https://i.stack.imgur.com/W8ckw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W8ckw.png" alt="Evenly distributed on all sides"></a></p>
  
  <p>I want to basically restrict points from going too far outwards from the center, so I get a result more like:</p>
  
  <pre><code>4 
  3 5 
  3 4 5 
  2 3 5 6 
  2 3 4 5 6 
  1 2 3 5 6 7 
  1 2 3 4 5 6 7 
  0 1 2 3 5 6 7 8 
  0 1 2 3 4 5 6 7 8
  </code></pre>
  
  <p>The following is an example graphical representation of the indeces shown in the output above:</p>
  
  <p><a href="https://i.stack.imgur.com/x4cBN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x4cBN.png" alt="Distributed evenly restricted from center"></a></p>
  
  <p>I'm using Java and this is my current code</p>
  
  <pre><code>int rowLength = 9;
  
  for (int points = 0; points &lt;= rowLength; points++) {
      for (float i = 0; i &lt; points; i++) {
          double result = Math.floor((i + 0.5) * rowLength / points);
  
          System.out.print((int) result + " ");
      }
  
      System.out.println();
  }
  </code></pre>
  
  <p>How can I best achieve the result shown in the second image so that the output from my code matches that of the second example output?</p>