Find the number which when added to the given ratio a : b , the ratio changes to c : d | Java implementation of the approach ; Function to return the required number X ; Driver code
import java . io . * ; class GFG { static int getX ( int a , int b , int c , int d ) { int X = ( b * c - a * d ) / ( d - c ) ; return X ; } public static void main ( String [ ] args ) { int a = 2 , b = 3 , c = 4 , d = 5 ; System . out . println ( getX ( a , b , c , d ) ) ; } }