• + 0 comments

    Java

    public static long strangeCounter(long t) {
            long maxSize = 3;
            long count = 0;
            while (count<t){
                    count+=maxSize;
                    maxSize*=2;
            }
            return (maxSize/2)-((maxSize/2)-((count-t)+1));
    }