Sum of two numbers if the original ratio and new ratio obtained by adding a given number to each number is given | Function to return the sum of numbers which are in the ration a : b and after adding x to both the numbers the new ratio becomes c : d ; Driver code
function sum ( a , b , c , d , x ) { var ans = ( x * ( a + b ) * ( c - d ) ) / ( ( a * d ) - ( b * c ) ) ; return ans ; } var a = 1 , b = 2 , c = 9 , d = 13 , x = 5 ; document . write ( sum ( a , b , c , d , x ) ) ;