Count unique paths in matrix from top left to bottom right

Given m x n matrix, count of all unique possible paths from top left to the bottom right. From each cell, only move right or down is allowed.

Hint

The algorithm determines the number of paths by starting at the destination and working backwards towards the source. At each step, the count is calculated by considering the possible paths from the current position: moving up and moving right.

# Python implementation
def count(m, n):
  if m == 1 or n == 1:
    return 1

  return count(m - 1, n) + count(m, n - 1)

m = 2
n = 2

print(count(m, n))
// Javascript implementation
function count(m, n) {
  if (m == 1 || n == 1) {
    return 1;
  }

  return count(m - 1, n) + count(m, n - 1);
}

const m = 2;
const n = 2;

console.log(count(m, n));