Let $p$ be a prime number. Determine all isomorphism classes of abelian groups $A$ that can appear as the middle term of a short exact sequence: $$0 \rightarrow \mathbb{Z}/(p^a) \rightarrow A \rightarrow \mathbb{Z}/(p^b) \rightarrow 0$$
Here is my attempt at this problem:
By the exactness of the sequence, $f: \mathbb{Z}/(p^a) \hookrightarrow A$, $g: A \twoheadrightarrow \mathbb{Z}/(p^b)$, and $Im(f) = Ker(g)$, so $Im(f) \cong \mathbb{Z}/(p^a)$, and thus by the First Isomorphism Theorem, $A/Ker(g) = A/Im(f) \cong A/(\mathbb{Z}/(p^a)) \cong Im(g) = \mathbb{Z}/(p^b)$. Since $\mathbb{Z}/(p^a)$ and $\mathbb{Z}/(p^b)$ are finite groups, $A$ is a finite group and hence finitely generated. Thus by Lagrange's Theorem, $|A| = |\mathbb{Z}/(p^a)||\mathbb{Z}/(p^b)| = p^{a+b}$. By the Fundamental Theorem of Finitely Generated Abelian Groups, $\displaystyle A \cong \mathbb{Z}^r \times \prod_{i = 1}^s \mathbb{Z}/(n_i)$ for some $r,s \geq 0$, $n_i \geq 2$, and $n_{i+1}|n_i$ for all $1 \leq i \leq s - 1$. Since $A$ is finite, $r = 0$ and $\displaystyle |A| = p^{a+b} = \prod_{i = 1}^s |\mathbb{Z}/(n_i)| = \prod_{i = 1}^s n_i$. Thus, the prime decomposition of each $n_i$ cannot have any primes other than $p$, so each $n_i$ is some power $m_i$ of $p$ so that $\displaystyle \sum_{i = 1}^s m_i = a+b$.
I want to prove that $A \cong \mathbb{Z}/(p^{a+b})$ but I am stuck at the last step of this proof. What we can conclude from the Fundamental Theorem is that $A$ is isomorphic to a product of cyclic groups of $p$-power order, but how can we prove that there is only one cyclic group factor in the factorization of $A$?
The only such groups will be $Z/(p^{a+b})$ and $Z/(p^{a})\times Z/(p^{b})$. To obtain this, one can use the two comments of @DerekHolt, and showing that considering $a\leq b$, $i$ has to be either $0$ or $a$, in the first comment of @DerekHolt. The problem for other $i$'s can be understood from the counterexample $p=2,a=2,b=3,i=1$.