Count of different straight lines with total n points with m collinear | Returns value of binomial coefficient ; $C [ 0 ] = 1 ; nC0 is 1 ; Compute next row of pascal triangle using the previous row ; function to calculate number of straight lines can be formed ; Driver Code
< ? php function nCk ( $ n , $ k ) { $ C = array_fill ( 0 , $ k + 1 , NULL ) ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) { for ( $ j = min ( $ i , $ k ) ; $ j > 0 ; $ j -- ) $ C [ $ j ] = $ C [ $ j ] + $ C [ $ j - 1 ] ; } return $ C [ $ k ] ; } function count_Straightlines ( $ n , $ m ) { return ( nCk ( $ n , 2 ) - nCk ( $ m , 2 ) + 1 ) ; } $ n = 4 ; $ m = 3 ; echo ( count_Straightlines ( $ n , $ m ) ) ; ? >