• + 0 comments

    Java solution:

    public static long cycleLength(long t){
        long sum = 0;
        long len = 3;
        while(true){
            sum = sum +len;
            if(sum >= t) return len;
            len = len * 2;
            }      
        }
        
      public static long strangeCounter(long t) {
        return 2 * cycleLength(t) - t - 2;
        }