  We have observed the primary electron spectrum from 30 GeV to 3 TeV using
emulsion chambers flown by balloons at the top of the atmosphere, for the
purpose of exploring the origin of cosmic rays in the Galaxy. The atmospheric
gamma rays have been simultaneously observed in the 30 GeV $\sim$ 8 TeV energy
range. In this paper, we estimate the atmospheric electron spectrum in the
upper atmosphere ($<$ 10 ${\rm g/cm^2}$) from our observed gamma-ray spectrum
using the electromagnetic shower theory in order to derive the primary
cosmic-ray electron spectrum. The transport equations of the electron and
gamma-ray spectrum are analytically solved and the results are compared with
those of Monte Carlo simulation (MC). Since we used the observed atmospheric
gamma rays as the source of atmospheric electrons, our solutions are free from
ambiguities on the primary cosmic-ray nuclear spectra and nuclear interaction
models included in MC. In the energy range above several hundred GeV, the
Dalitz electrons produced directly from neutral pions contribute around 10
percent to the whole atmospheric electron spectrum at the depth of 4 ${\rm
g/cm^2}$, which increases in importance at the higher altitude and cannot be
ignored in TeV electron balloon observations.
