/**
 * Compute the number of paths from (1,1) to (n,n).  N is given on
 * the command line.  Is not very friendly about errors.
 *
 * @author Samuel A. Rebelsky
 * @version 1.0 of October 1999
 */
public class NumPaths {
  /**
   * The number of recursive calls.
   */
  protected int calls = 0;

  /**
   * Compute the number of paths from (row,col) to (n,n).
   * (row,col) should not be (n,n).
   */
  public int numPaths(int row, int col, int n)
  {
    calls++;
    if (row == n)
      return 1;
    else if (col == n)
      return 1;
    else
      return numPaths(row+1, col, n) + numPaths(row, col+1, n);
  } // numPaths(int, int, int)

  public static void main(String[] args) {
    SimpleOutput out = new SimpleOutput();
    int n = Integer.parseInt(args[0]);
    NumPaths helper = new NumPaths();
    int count = helper.numPaths(1,1,n);
    out.println("There are " + count + " paths to (" + n + "," + n + ")");
    out.println("  That took " + helper.calls + " calls.");
  } // main(String[])
} // NumPaths

