int i = 1024; while(i > 0){ System.out.println(i); i >>= 1; //also acceptable: i /= 2; }