We study the system of two ultracold atoms in a three-dimensional (3D) or two-dimensional (2D) completely anisotropic harmonic trap. We derive the algebraic equation J3D(E) = 1/a3D (J2D(E) = ln a2D) for the eigen-energy E of this system in the 3D (2D) case, with a3D and a2D being the corresponding s-wave scattering lengths, and provide the analytical expressions of the functions J3D(E) and J2D(E). In previous researches this type of equation was obtained for spherically or axially symmetric harmonic traps (T. Busch, et. al., Found. Phys. 28, 549 (1998); Z. Idziaszek and T. Calarco, Phys. Rev. A 74, 022712 ( 2006)). However, for our cases with a completely anisotropic trap, only the equation for the ground-state energy of some cases has been derived (J. Liang and C. Zhang, Phys. Scr. 77, 025302 ( 2008)). Our results in this work are applicable for arbitrary eigen-energy of this system, and can be used for the studies of dynamics and thermal-dynamics of interacting ultracold atoms in this trap, e.g., the calculation of the 2nd virial coefficient or the evolution of two-body wave functions. In addition, our approach for the derivation of the above equations can also be used for other two-body problems of ultracold atoms.