text: Counts paths from a point to reach Origin | Java Program for above approach ; utility min ; Function for binomial Coefficient ; Constructing Pascal 's Triangle ; Driver Code
code: import java . io . * ; import java . util . * ; class GFG { static int min ( int a , int b ) { return a < b ? a : b ; } static int binomialCoeff ( int n , int k ) { int C [ ] = new int [ k + 1 ] ; C [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = min ( i , k ) ; j > 0 ; j -- ) C [ j ] = C [ j ] + C [ j - 1 ] ; } return C [ k ] ; } public static void main ( String [ ] args ) { int n = 3 , m = 2 ; System . out . println ( " Number ▁ of ▁ Paths : ▁ " + binomialCoeff ( n + m , n ) ) ; } }