function res= corrmu(l)



    function[vec2] = bas(x)
        b = base3(x);
        bas = b(2,b(1,1:end)==1);
        vec2 = bas;
    end;
  


    function[vec1] = produ1(v)
        for k = 1:(m-1)
            produ1(k) = 2^(2*(N-v(k+1)));
        end
     vec1 = produ1;
    end;

    function[vec] = produ(v)
        p = produ1(v);
        for k = 2:m-1
            if mod(k,2) == 0
        produ(k) = prod(p(1:k-1))*2^(2*(N-v(k+1)));
            else
        produ(k) = prod(p(1:k-1))*2^((N-v(k+1)));
            end
        end
    produ(1) =  2^(2*(N-v(2)));
    vec = produ;
    end;
        

%for k=2:size(w)
 %   if mod(k,2) == 1
 %   prod(k) = prod(k-1)*2^(2*(w(k)-N))
 %   else 
 %       prod(k) = prod(k-1)*2^((w(k)-N))
 %   end
%end
    function [vec] = equiv(x)
        mem = x;
        incr = 0;
        while (mem > 1)
            mem = mem/3;
            incr = incr+1;
        end
    vec(1) = mem;
    vec(2) = incr;
    end;
    

        

    vequiv = equiv(l);
    ll = vequiv(1);
    ii = vequiv(2);

    w = bas(ll);
    n = size(w);
    m = n(2);
    N = w(1);
    

     if ll==1
         res = 2^(ii);
     else
         res = 2^(ii)*(0.5*2^(-N)*sum(produ(w))+ 2^(-N));
     end
     
     
     res;
     
     
  

end
    
    