title: Using Modulus operator in for-loop
body: <p>I've been trying to get the output to print that after every 6 numbers, a newline is added. However, it's not working as intended. If user enters 9 in the main function, it should print out: </p>
  
  <pre><code>21    13    8     5     3     2  
  1     1     0
  </code></pre>
  
  <p>but instead is printing</p>
  
  <pre><code>21   13
  8     5    3    2    1    1
  0
  </code></pre>
  
  <p>Almost correct but not quite. How do I go about fixing this? I'm not sure if it's because of my indexing or if I'm incorrectly using the modulus operator. Thank you!</p>
  
  <p>My code:</p>
  
  <pre><code>void Fibonacci(int length)
  {
  
      int arr[20] = {0, 1, 1, 2, 3, 5, 8, 13, 21,
                     34, 55, 89, 144, 233, 377,
                      610, 987, 1597, 2584, 4181};
  
      for (int i = length - 1; i &gt;= 0; --i)
      {
  
          if (i % 6 == 0 )
          {
  
             cout&lt;&lt;endl;
  
          }
          cout&lt;&lt;setw(5)&lt;&lt;arr[i];
  
      }
      cout&lt;&lt;endl;
  </code></pre>