How can efficiently derive $x$ and $y$ from $z$ where $z=2^x+3^y$. How can efficiently derive $x$ and $y$ from $z$ where $z=2^x+3^y$.
Note. $x$,$y$ and $z$ are integer values and $z$ is $4096$ bits integer or even more.
For all $z>1$.
And if equation be $z$=$2^x$.$3^y$ then what is your answer?
 A: We don't know which, but either $2^x$ is larger or $3^y$ is larger. (They can't be equal.)


*

*Suppose $3^y$ is larger. Then, when you write $z$ in base $3$, you'll see a $1$ in the $y$th position, the rest of the digits correspond to the power of $2$. To put this differently: take the largest power of $3$ less than $z$, and suppose it is $3^y$. Then if $z - 3^y$ is a power of $2$, you are done.

*Suppose $2^x$ is larger. Then when you write $z$ in base $2$, you'll see a $1$ in the $x$th position, and the rest of the digits correspond to the power of $3$. Algorithmically: take the largest power of $2$ less than $z$, call it $2^x$, and check whether $z - 2^x$ is a power of $3$.
This is sufficient to be an algorithm.
A: Here's a hint: Take $z \equiv 2^{x}\mod 3$. What are the powers of two modulo $3$? Can you spot a pattern?  
Here's an example: Let, say, $z=1105$. So we want to find non-negative integers $x,y$ with $z=2^{x}+3^{y}$ (presumably we are given that this is possible). Consider the equation modulo 3.
$$z \equiv 2^{x} \mod 3 \quad \mbox{and}\quad 1105 \equiv 1 \mod 3$$
Now consider the sequence $2^{n} \mod 3$ for $n =0,1,2 \ldots$: the terms alternate $1,2,1,2 \ldots$; $1$ if $n$ is even and $2$ if $n$ is odd - so we can say that $x$ is even in our case above - let us write $x=2a$.  
Therefore, we have that $z=4^{a}+3^{y}$. Take the equation modulo 4 now and apply a similar procedure. Repeat until it is obvious to halt (and it is obvious).
A: If $z = 2^x \ 3^y$, then define $a_k = {\log_2 (z) \over{2^k}}$ rounded to the nearest integer.
Let $k = 2$ and $\beta = a_1$
If $ z \equiv_{2^\beta} 0$, $\beta \to \beta + a_k$
Else, $\beta \to \beta - a_k$
Regardless, $k \to k+1$
Repeat until $a_k = 0$, then $x \in \{\beta-1, \beta, \beta+1 \}$ (simple to check which)
After you know $x$, it becomes clear that $y = \log_3 ({z \over{2^x}})$ 
A: In most cases, the solution doesn't exist. As others pointed out, if $z=0\mod 3$, then there's no solution.
If $z=\pm 1 \mod 3$, then you have $x$ that is even (plus)/ odd (minus). Even if $z$ has 4k bits, it's still reasonable to try all $x$ (2048 checks are no big deal).
5-minute python code (if no arg given, just goes through first million), printing all solutions it finds:
#!/usr/bin/python
import sys
#check if a power of 3
def check_3(z):
    y=0
    while z%3 == 0:
       y+=1
       z/=3
    return y if z==1 else None

def fun(z):
    if z%3 == 0:
        return None

    if z%3 == 2:
        x=1
        xfactor=2
    else:
        x=0
        xfactor=1
    while xfactor<z:
        remainder=z-xfactor
        if remainder%3 == 0:
            y=check_3(remainder)
            if y:
                return (x,y)

        x+=2
        xfactor*=4

    return None


if len(sys.argv)>1:
    z=int(sys.argv[1])
    r=fun(z)
    if r:
        x,y=r
        print(z,x,y)
    else:
        print(z,"no solution")
else:
    for z in range(1,2<<20):
        r=fun(z)
        if r:
            x,y=r
            print(z,x,y)

