In Gallian's Contemporary Abstract Algebra, he mentioned about this Greedy Algorithm for an Abelian group. It's basically a procedure of expressing a finite Abelian group as an internal direct product. But the validity of the algorithm is not clear.
I included the algorithm here:
Greedy Algorithm for an Abelian Group of Order $p^n$ ($p$ is prime)
- Compute the orders of the elements of the group $G$.
- Select an element $a_1$ of maximum order and define $G_1=\langle a_1\rangle$.
- If $|G_1|=|G|$, stop. Otherwise, replace $i$ by $i+1$.
- Select an element $a_i$ of maximum order $p^k$ such that $p^k\leq|G|/|G_i|$ and none of $a_i$, $a_i^p$, $a_i^{p^2}$,..., $a_i^{p^{k-1}}$ is in $G_i$ and define $G_i=G_{i-1}\times\langle a_i\rangle$.
- Return to Step 3.
Internal direct product requires that none of the elements of $\langle a_i\rangle$ except identity should be in $G_{i-1}$ so why the condition in step 4 is weaker?