import math


def euler15(n, m):
  """Number of distinct Manhattan paths from one side to the other of an n x m grid
     http://projecteuler.net/problem=15"""
  # You have to walk N + M blocks, of which N have to be horiz and M vertical.
  # The # of paths is the number of ways to arrange the N horiz blocks within
  # the N+M blocks walked: c(N+M, N) = (N+M)!/(N! * M!)
  return math.factorial(n+m)/(math.factorial(n) * math.factorial(m))