Count number of ways to divide a number in 4 parts | Returns count of ways ; Initialize result ; Generate all possible quadruplet and increment counter when sum of a quadruplet is equal to n ; Driver Code
< ? php function countWays ( $ n ) { $ counter = 0 ; for ( $ i = 1 ; $ i < $ n ; $ i ++ ) for ( $ j = $ i ; $ j < $ n ; $ j ++ ) for ( $ k = $ j ; $ k < $ n ; $ k ++ ) for ( $ l = $ k ; $ l < $ n ; $ l ++ ) if ( $ i + $ j + $ k + $ l == $ n ) $ counter ++ ; return $ counter ; } $ n = 8 ; echo countWays ( $ n ) ; ? >