*Now cross-posted to Mathoverflow.*

Is there an infinite topological space $X$ with only countably many continuous functions to itself? Such a space would have only countably many points because the constant functions are continuous. A space with countably many points such that only the constant functions and the identity are continuous would work. I wasn't able to find something: all the topological spaces I can think of have $2^{\aleph_0}$ continuous maps to themselves.

We cannot find a counterexample among the metrizable spaces. Let $X$ be an infinite countable metric space with metric $d$.

If $X$ is discrete, it is clearly false, so suppose that there is some point $x$ which is not isolated. Let $(r_i)_{i \in \mathbb{N}}$ be a strictly decreasing sequence of real numbers converging to $0$ such that for any $n \in \mathbb{N}$, there is no point $y$ with $d(x,y) = r_n$, and such that there is a point $y$ with $r_n > d(x,y) > r_{n+1}$.

We define $$B_{n+1} = \{y \in X \mid r_n > d(x,y) > r_{n+1} \}\space \text{and} \space B_0 = \{y \in X \mid d(x,y) > r_0 \}$$ For any integer $n$, we choose such a point $y_n$ in $B_n$.

Then, we can define the continuous function $$f : X \to X \space \text{as} \space f(x) = x \space \text{and} \space f(y) = y_n \space \text{for}\space y \space \text{in}\space B_n$$ Then, for each $n \in \mathbb{N}$, you can choose to swap $y_{2n}$ and $y_{2n+1}$ or not, giving you $2^{\aleph_0}$ continuous maps.

Another large class of examples that I know of are Alexandrov topologies, however, each Alexandrov topology corresponds to a preorder, and the continuous maps between two Alexandrov topologies correspond to the morphisms between the preorders. An infinite countable preorder has always $2^{\aleph_0}$ endomorphisms, hence I cannot find a counterexample there either.

I looked for other examples in the *Counterexamples in topology* book, but nothing looked promising (not that I proved it for every countable space in the book.)

More generally, for any infinite cardinal $\kappa$, is there a topological space with $\kappa$ points and exactly $\kappa$-many continuous maps to themselves? An obvious example for $2^{\aleph_0}$ is $\mathbb{R}$ with the euclidean topology.

In fact, for any infinite cardinal $\kappa$, seeing $\kappa$ as a discrete space, we can define the space $X = \kappa^{\aleph_0}$ with the product topology, and this space has $2^\kappa$ continuous functions from itself to itself, because the continuous functions $f : X \to X$ are determined by their values on the sequences which are eventually constant. Hence, for any cardinal $\kappa$ such that $2^\kappa = \kappa^{\aleph_0}$, we know that the answer is positive for $2^\kappa$.

Edit: Using the $\pi$-Base, an online database of topological spaces inspired by the book *Counterexamples in topology* and expanding it, I obtained this list of possible spaces. I proved for every one of these spaces that there were too many continuous maps, except for the Relatively prime integer topology (also known as the Golomb space) and the Prime integer topology. The first one was proved to have too many continuous maps, and the second one is very similar to the first one, so I don't place much hope on it. We need to look somewhere else. Here's my last idea: if we take $F$ a filter on $\mathbb{N}$, adding the empty set, we obtain a topological space. Could some space obtained this way have only countably many continuous functions to itself? Could it be always true if the filter is an ultrafilter? I don't know how to answer this question.