日期:2014-05-20 浏览次数:20722 次
public class Test1 { public static void main(String[] args) { int n = 31; if(n < 1) { return; } int count = 0; while(n != 1) { if(n % 2 == 0) { n /= 2; } else { if((n & 2) == 0 || n == 3) { n--; } else { n++; } } count++; System.out.println(count + ": " + n); } System.out.println("Total: " + count); } }