/* Rectangular playing board with nrows and ncols. Robot is in upper left corner, must move one square at a time (right and down) to lower right corner. How many possible paths? */ import java.util.ArrayList; import java.util.List; public class Robot { public static void main(String[] args) { int nrows = 3; int ncols = 3; System.out.println(numberOfPaths(nrows, ncols)); System.exit(0); } private static int numberOfPaths(int nrows, int ncols) { assert nrows >= 1 && ncols >= 1; if (nrows == 1 || ncols == 1) { return 1; } return numberOfPaths(nrows - 1, ncols) + numberOfPaths(nrows, ncols - 1); } }