Maximize count of distinct profits possible by N transactions | Function to count distinct profits possible ; Stores the minimum total profit ; Stores the maximum total profit ; Return count of distinct profits ; Input ; Function call
function numberOfWays ( N , X , Y ) { let S1 = ( N - 1 ) * X + Y ; let S2 = ( N - 1 ) * Y + X ; return ( S2 - S1 + 1 ) ; } let N = 3 ; let X = 13 ; let Y = 15 ; document . write ( numberOfWays ( N , X , Y ) ) ;