// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class Test {
    private final static int REP = 10;
    private final static int M = 10000;
    private final static int N = 1000000;
    public static void testint() {
        long t1 = System.currentTimeMillis();
        for(int i = 0; i < M; i++) {
            int sum = i;
            for(int j = 0; j < N; j++) {
                sum = ((sum + 1) * 2 + 1) / 2;
            }
            if(sum != (i + N)) {
                System.out.println("Error");
                System.exit(0);
            }
        }
        long t2 = System.currentTimeMillis();
        System.out.println((t2-t1)/1000 + " seconds");
    }
    public static void main(String[] args) {
        for(int i = 0; i < REP; i++) {
            testint();
        }
    }
}
