Hook walk terminal probability (source code)

= Hook walk terminal probability
{title2=$p(\alpha,\beta\mid a,b)$}

For a target corner $(\alpha,\beta)$ in the <Greene–Nijenhuis–Wilf hook walk>, put $A_i=h(i,\beta)-1$ and $B_j=h(\alpha,j)-1$. The probability of terminating there from $(a,b)$ factors as $F_aG_b$, where $F_\alpha=G_\beta=1$, $F_a=A_a^{-1}\prod_{i=a+1}^{\alpha-1}(1+A_i^{-1})$ for $a<\alpha$, and $G_b=B_b^{-1}\prod_{j=b+1}^{\beta-1}(1+B_j^{-1})$ for $b<\beta$. It is zero when the start is outside the target's northwest rectangle. The factorization uses $h(i,j)-1=A_i+B_j$ and the first-step recurrence.