If $m,n \in \mathbb{N}$ . Let $g(m, n)$ be the number of cells that the line joining $(m, n)$ to $(0, 0)$ cuts in the region $0 \le x \le m$ and $0 \le y ≤ n$.
For example $g(1, 1)$ is $1$ because the line joining $(1, 1)$ and $(0, 0)$ cuts just one cell. Similarly $g(2, 1)$ is $2$ and $g(3, 2) = 4$.
Find $g(343, 56)$.
I am trying to derive a formula for any $g(m,n)$. I noticed that for $m=n$ the answer is $m$ but for $m \neq n$ the answer seems be $(m+n-1)$ in general but this does not holds for all. Any ideas how to generalize $m \neq n$ restriction?