Minimum steps to convert X to Y by repeated division and multiplication | Java 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
class GFG { static int solve ( int X , int Y ) { if ( X > Y ) { int temp = X ; X = Y ; Y = temp ; } if ( X == Y ) System . out . println ( 0 ) ; else if ( Y % X == 0 ) System . out . println ( 1 ) ; else System . out . println ( 2 ) ; return 0 ; } public static void main ( String args [ ] ) { int X = 8 , Y = 13 ; solve ( X , Y ) ; } }