title: Generating Pyramid to Show Numbers in Module 10
body: <p>I am trying to generate pyramid starts with the number one (1), in each row the first digit determines the number of row. In addition, the first number in the row also determines the number of numbers in that order (according to module 10). All other numbers in a row we calculate by adding the number from the left and the number above it, according to module 10.</p>
  
  <pre><code>int n = 12;
  int i, j;
  
  for (i = 1; i &lt;= n; i++) {
      for (j = 0; j &lt;= i; j++) {
        int module = i % 10;
  
        System.out.print(module + " ");
  
      }
  
      System.out.println();
    }
  }
  
  </code></pre>
  
  <p>With my implementation, I get</p>
  
  <pre><code>1 1 
  2 2 2 
  3 3 3 3 
  4 4 4 4 4 
  5 5 5 5 5 5 
  6 6 6 6 6 6 6 
  7 7 7 7 7 7 7 7 
  8 8 8 8 8 8 8 8 8 
  9 9 9 9 9 9 9 9 9 9 
  0 0 0 0 0 0 0 0 0 0 0 
  1 1 1 1 1 1 1 1 1 1 1 1 
  2 2 2 2 2 2 2 2 2 2 2 2 2 
  </code></pre>
  
  <p>The actual result should be</p>
  
  <pre><code>1
  2 3
  3 5 8
  4 7 2 0
  5 9 6 8 8
  6 1 0 6 4 2
  7 3 4 4 0 4 6
  8 5 8 2 6 6 0 6
  9 7 2 0 2 8 4 4 0
  0 9 6 8 8 0 8 2 6 6
  1 1 0 6 4 2 2 0 2 8 4
  2 3 4 4 0 4 6 8 8 0 8 2
  </code></pre>
  
  <p>What am I missing?</p>