You have a grid with `$m$` rows and `$n$` columns. Return the number of unique ways that start from the top-left corner and go to the bottom-right corner. You are only allowed to move right and down.

For example, in the below grid of `$2$` rows and `$3$` columns, there are `$10$` unique paths:

```
o----o----o----o
|    |    |    |
o----o----o----o
|    |    |    |
o----o----o----o
```

**Note:** there are random tests for grids up to 1000 x 1000 in most languages, so a naive solution will not work.

---
*Hint: use mathematical permutation and combination*

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Mathematics

Starter code: def number_of_routes(m, n):
	

Solutions:
from math import factorial as f
number_of_routes = lambda m, n: f(m + n) // (f(m) * f(n))


import sys
sys.setrecursionlimit(1200)
cache = {}

def number_of_routes(m, n):
	if m == 0 or n == 0:
		return 1
	if m > n:
		return number_of_routes(n, m)
	result = cache.get((m, n))
	if result is None:
		cache[m, n] = result = number_of_routes(m - 1, n) + number_of_routes(m, n - 1)
	return result


from operator import mul
from functools import reduce

def choose(n, p):
	if p > n:
		return 0
	if p > n - p:
		p = n - p
	return reduce(mul, range(n - p + 1, n + 1), 1) // reduce(mul, range(1, p + 1), 1)

def number_of_routes(m, n):
	return choose(m + n, n)