Number of solutions for x < y , where a <= x <= b and c <= y <= d and x , y are integers | function to Find the number of solutions for x < y , where a <= x <= b and c <= y <= d and x , y integers . ; to store answer ; iterate explicitly over all possible values of x ; return answer ; Driver code ; function call
< ? php function NumberOfSolutions ( $ a , $ b , $ c , $ d ) { $ ans = 0 ; for ( $ i = $ a ; $ i <= $ b ; $ i ++ ) if ( $ d >= max ( $ c , $ i + 1 ) ) $ ans += $ d - max ( $ c , $ i + 1 ) + 1 ; return $ ans ; } $ a = 2 ; $ b = 3 ; $ c = 3 ; $ d = 4 ; echo NumberOfSolutions ( $ a , $ b , $ c , $ d ) ; ? >