m x n grid and can only move right or down. Implement count_paths(m, n) returning the number of distinct paths to the bottom-right corner, using pure tree-like recursion: each cell branches into the path count of the cell to its right plus the cell below it.count_paths(3, 3)
6
A 3x3 grid has C(4,2) = 6 distinct right/down paths.
count_paths(1, 5)
1
A single row only has one path: straight across.
Base case: if m == 1 or n == 1, there is exactly 1 path.
Recursive case: count_paths(m - 1, n) + count_paths(m, n - 1).