Make A , B and C equal by adding total value N to them | JavaScript program to distribute integer N among A , B , C such that they become equal ; Find maximum among the three elements ; Summation of three elements ; Check if difference is divisible by 3 ; Driver code
function distributeN ( A , B , C , n ) { let max1 = Math . max ( A , B ) ; let max2 = Math . max ( B , C ) ; let maximum = Math . max ( max1 , max2 ) ; let sum = A + B + C ; let p = ( 3 * maximum ) - sum ; let diff = n - p ; if ( diff < 0 diff % 3 ) document . write ( " " ) ; else document . write ( " " ) ; } let A = 10 , B = 20 ; let C = 15 , n = 14 ; distributeN ( A , B , C , n ) ;