When are all continuous self-maps of a topological spaces generated by retractions and self-homeomorphisms of prime order? This is probably a very basic question, but I don't know the answer and I also don't see how it might be obvious (which it very well might be).
Given a topological space $X$, when is the set of all its continuous self-maps generated by the subset consisting of


*

*the self-homeomorphisms of prime order (i.e., there exists some prime number $p$ such that $f^p = id$ while $f^k \neq id$ for all $k \leq p$) and

*the continuous retractions (i.e. $f^2 = f$)?


Is the answer to this a well-known fact? Is there a characterization of the cases where it is true?
I should add that, by generation, I mean everything you can get by applying composition finitely many times.

Edit: I originally also asked whether the statement is true or not. A counterexample was quickly presented by James Cranch (see below), so I have put more emphasis on a different part of my question, namely if there is a characterization of the cases where the statement is true.
 A: This is most likely pretty rare. Let G be any finite group. Then Birkhoff proved that G is the automorphism group of a finite distributive lattice L. The G is the group of homomorphisms of the space of prime filters on L with the usual kernel-hull topology.  Thus any finite group is the homeomorphism group of a finite topological space but need not be generated by elements of prime order. 
Added.In fact any group is the homeomorphism group of a topological space, including torsion-free ones and any monoid can be the set of nonconstant selfmaps of a space. See What sets of self-maps are the continuous self-maps under some topology?. 
A: It is not always the case; a counterexample is given by a degree-2 self-map of the circle.
A continuous retraction satisfies $\deg(f)^2 = \deg(f^2) = \deg(f)$ and hence has degree either $0$ or $1$. Meanwhile, the self-homeomorphisms have invertible degree, which must therefore be $\pm1$.
Compositions of these have degree $-1, 0$ or $1$.
A: Here is s a different reason why the property is rare:
Consider a topological space $X$ with a continuous surjection $f \colon X \rightarrow X$ that is not a homeomorphism. Assume $f = g_n \circ \ldots \circ g_1$, where each $g_i$ is a
homeomorphism or a continuous retraction. 
Since $f$ is surjective, $g_n$ must be surjective and is hence not a nontrivial retraction. It follows that it must be a homeomorphism. We obtain 
$g_n^{-1} \circ f = g_{n-1} \circ \ldots \circ g_1$, and we can repeat the arguments to 
conclude each $g_i$ is a homeomorphism. Thus $g_n \circ \ldots \circ g_1$ is a homeomorphism, 
whereas $f$ is not. Contradiction.
Thus, the statement fails whenever the space has a continuous surjective selfmap that is not a homeomorphism. Thus, it even fails for discrete spaces of infinite cardinality.
