Minimum steps to convert X to Y by repeated division and multiplication | Javascript implementation to find minimum steps to convert X to Y by repeated division and multiplication ; Check if X is greater than Y then swap the elements ; Check if X equals Y ; Driver code
function solve ( X , Y ) { if ( X > Y ) { let temp = X ; X = Y ; Y = temp ; } if ( X == Y ) document . write ( 0 ) ; else if ( Y % X == 0 ) document . write ( 1 ) ; else document . write ( 2 ) ; } let X = 8 , Y = 13 ; solve ( X , Y ) ;