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