Solutions to $a^x = b^y$ Given $a$ and $b$.Find $x$ and $y$ such that 
$$a^x = b^y$$
$$a, b, x, y \in \Bbb N^+$$
If any $x$ and $y$ exists.
In my actual problem I know that $x$ and $y$ both $< 6$ (but I'm looking for a general solution, that is, not a brute force search over 25 possibilities).
$a$ and $b$ can be as low as $2$ or as high as $60000000$.
Examples


*

*$a = 4, b = 8, x = 3, y = 2$

*$a = 2, b = 2^{20}, x = 20, y = 1$

*$a = 49, b = 7, x = 1, b = 2$


Possible solution (please comment)
Prime factorization of both $a$ and $b$ gives:
$$a = {p_1}^{e_1} {p_2}^{e_2} {p_3}^{e_3} ... {p_n}^{e_n}$$
$$b = {q_1}^{f_1} {q_2}^{f_2} {q_3}^{f_3} ... {q_n}^{f_n}$$
($p_i$ and $q_i$ prime, $p_1 < p_2 < p_3 < ... < p_n$, $q_1 < q_2 < q_3 < ... < q_n$, $e_i$ and $f_i$ positive integer)
If for any $i$, $p_i \neq q_i$ then no solution exists.
Otherwise let $$m = LCM(e_1, f_1)$$ $$x = m/e_1$$ $$y = m/f_1$$
Then $x$ and $y$ will be the solution iff $$x e_i = y f_i$$ for every $1 \le i \le n$
 A: Let $p_1, p_2, ...$ be the infinite sequence of positive prime integers, in increasing order (that is, $2, 3, ...$). Every positive integer corresponds bijectively to a sequence of non-negative exponents $e_1, e_2, ...$ - the exponents in the prime decomposition of the integer. The sequence has finite support - that is, all but a finite number of the $e_j$ are zero.
So now you have two "vectors" in $\Bbb N^+ \times \Bbb N^+ \times \cdots$, one for $a$ and one for $b$. The condition for the equation to have any solutions is that the two vectors be proportional, that is, they have exactly the same support (set of $j$ for which the $e_j$ are non-zero) and for those $j$, $e_j / e'_j$ is independent of $j$, where the $e_j$ are the exponents for $a$ and the $e'_j$ for $b$. And then $y/x$ as a rational number must equal the common value of all those fractions.
A: The existence of $x$ and $y$ depends on the prime factorisation of $a$ and $b$. 
Let $a=\prod_{n=1}^f {p_n}^{c_n}$ and $b=\prod_{n=1}^g {q_n}^{d_n}$ (both in the form of their prime factors).
Obviously, without loss of generality, 
1) $f=g$ 
2) $p_n=q_n$ for all $n$
3) $xc_n=yd_n$ for all $n$
In other words, the ratio of the exponents within the factorisation must be the same in both numbers. In all other cases, $a^x\neq b^y$.
