Problem statement :
On a positive integer, you can perform any one of the following 3 steps.
This works :)
import java.util.Scanner;
public class MinimumStepToOne {
public static void main(String[] args){
Scanner sscan = new Scanner(System.in);
System.out.print("Give a no:" + " ");
int n = sscan.nextInt();
int count = 0;
for(int i = 0; n > 1; i++){
if(n%2 == 0){n /= 2; count++;}
else if(n%3 == 0){ n /= 3; count++;}
else { n -= 1; count++;}
}
System.out.println("your no is minimized to: " + n);
System.out.println("The min no of steps: " + count);
}
}