title: Pascal Triangle - Print only 'n'th line
body: <p>Here is some code for outputting a Pascal Triangle, and it shows all of the lines of the triangle. For example, if user input is 5 then it will output as follows:</p>
  
  <pre><code>1
  1 1
  1 2 1
  1 3 3 1
  1 4 6 4 1
  </code></pre>
  
  <p>I just want it to output the last line, though. So for 5, only 1 4 6 4 1. I'm having trouble accomplishing this, though it's easy enough, I know. Any help is appreciated.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class PascalsTriangle {
      public static void computeRow(int n) {
         int counter;
         for (int i = 0; i &lt; n; i++) {
             for (int j = 0; j &lt;= i; j++) {
                 System.out.print(pascalValue(i, j) + " ");
             }
             System.out.println();
          }
      }
  
      public static int pascalValue(int i, int j) {
          if (j == 0) {
              return 1;
          } else if (j == i) {
              return 1;
          } else {
              return pascalValue(i - 1, j - 1) + pascalValue(i - 1, j);
          }
      }
  
      public static void main(String[] args) {
          Scanner scanner = new Scanner(System.in);
          System.out.print("Which line number of Pascal's Triangle? ");
          int row = scanner.nextInt();
          System.out.print("Line " +row+" of Pascal's Triangle:\n");
          computeRow(row);
      }
  }
  </code></pre>