We calculate energy levels of two and three bosons trapped in a harmonic oscillator potential with oscillator length
aosc. The atoms are assumed to interact through a short-range potential with a scattering length
a, and the short-distance behavior of the three-body wave function is characterized by a parameter $\ensuremath{\theta}$. For large positive
a/aosc, the energies of states that, in the absence of the trap, correspond to three free atoms approach values independent of
a and $\ensuremath{\theta}$. For other states, the $\ensuremath{\theta}$ dependence of the energy is strong, but the energy is independent of
a for $|a/{a}_{\mathrm{o}\mathrm{s}\mathrm{c}}|\ensuremath{\gg}1$.
We develop an analytical many-body wave function to accurately describe the crossover of a one-dimensional bosonic system from weak to strong interactions in a harmonic trap. The explicit wave function, which is based on the exact two-body states, consists of symmetric multiple products of the corresponding parabolic cylinder functions and respects the analytically known limits of zero and infinite repulsion for arbitrary number of particles. For intermediate interaction strengths we demonstrate that the energies, as well as the reduced densities of first and second order, are in excellent agreement with large scale numerical calculations.