Function to return the number of ways to reach ( X , Y ) in a matrix with the given moves starting from the origin
function ways ( x , y ) { factorialfun ( ) ; modinversefun ( ) ; if ( ( 2 * x - y ) % 3 == 0 && ( 2 * y - x ) % 3 == 0 ) { let m = parseInt ( ( 2 * x - y ) / 3 , 10 ) ; let n = parseInt ( ( 2 * y - x ) / 3 , 10 ) ; System . out . println ( n + m + " " + n ) ; return binomial ( ( n + m ) , n ) ; } return 0 ; }