I have been trying to make this code go faster by trying to write it more efficiently and I don't know what else to do. I got it to 30 seconds but I have seen 23 and 24 and I have no idea on how to do it.    public class Main {    public static void main(String[] args) {        long startTime = System.currentTimeMillis();        for(long n = 1; n <= 100000000; n+=2){            long value = cycleLength(n);            if(value > (n*n)){                System.out.println(n +   + value);            }        }        long endTime = System.currentTimeMillis();        System.out.println(Runtime =  + (endTime - startTime) +  milliseconds);    }//main    public static long cycleLength(long n) {        long hi = n;        while (n > 1) {            if((n&1)==0)  // bitwise AND                n = n >> 1;  // n even            else {                n = 3*n+1; // n odd                if(hi < n)                    hi = n;                n = n >> 1;            }        }        return hi;    }}
Speeding up 3n+1 challenge
java;performance