Is there an infinite topological space with only countably many continuous maps to itself?

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.


I have something that I know is not a complete answer, but I think good enough to put here as an extended comment.

First I thought the question might be related to rigid spaces, i.e. where the only autohomeomorphism is the identity. So I googled countable rigid topological space.

One if the results was the following paper:
ADVANCES IN MATHEMATICS 29 (1978), 89-130
Constructions and Applications of Rigid Spaces, I
V. Kannan, M. Rajagopalan
https://www.sciencedirect.com/science/article/pii/0001870878900063

In section 2 (p.103 of their paper) they discuss strongly rigid spaces:
A Hausdorff space $X$ is said to be strongly rigid if every continuous self-map of $X$ is either the identity map or a constant map.

They discuss the difficulties in finding such spaces, but they have a construction which seems to answer the above question under the assumption that $\mathfrak c^+<2^{\mathfrak c}$ where $\mathfrak c=2^{\aleph_0}$. (Pretty long, I just glanced through the paper, they work with $\beta D$ where $D$ is discrete of infinite cardinality $m$, and their assumption is $(2^m)^+<2^{2^m}$; the main idea seems to be that $\beta D\setminus D$ contains many points of "different topological type", some results of Kunen. Or rather, I assumed it related to some results of Kunen, but looking again I see that the authors use the following result of Hajnal:
THEOREM. Let $D$ be an infinite discrete space of cardinality $m$. Assume $(2^m)^+<2^{2^m}$. Then every closed subset of $\beta D\setminus D$ having cardinality $2^{2^m}$ contains a subset of cardinality $2^m$ in which no two elements are comparable.
One may want to review Kunen's later results, to see if the condition $(2^m)^+<2^{2^m}$ could possibly be removed.)

See in particular Theorem 2.5.6 (p.124) and Remark 2.5.8 (p.127).

THEOREM 2.5.6. The space $S$ (of Construction 2.5.3) has the following properties:
(1) $S$ is a Hausdorff space.
(2) $S$ is connected. In fact, both $S\setminus\{\infty\}$ and $S\setminus\{-\infty\}$ are connected.
(3) $|S| = m.$
(4) $S$ is strongly rigid.

Of course, when $m=\aleph_0$ and $(2^{\aleph_0})^+<2^{2^{\aleph_0}}$ then we get a countable strongly rigid space $S$, and in particular only countably many continuous functions to itself, namely the identity map and all constant maps.

(Their Remark 2.5.8. We believe that we have given the first example of a countable strongly rigid space. Note that even countable connected Hausdorff spaces are rare ([22]).)

Some other papers that google showed me and might be relevant:
PACIFIC JOURNAL OF MATHEMATICS Vol. 70, No. 2, 1977
COUNTABLE SPACES WITHOUT POINTS OF FIRST COUNTABILITY
RONNIE LEVY
https://projecteuclid.org/journals/pacific-journal-of-mathematics/volume-70/issue-2/Countable-spaces-without-points-of-first-countability/pjm/1102811927.pdf

ADVANCES IN MATHEMATICS 52, 1-33 (1984)
A Compact Space with a Measure That Knows Which Sets Are Homeomorphic
ERIC K. VAN DOUWEN
https://core.ac.uk/download/pdf/82152871.pdf

REMARK. It is a trivial remark, but just for the record, it is easy to see (and essentially already noted by the OP) that any example (of a space with only countably many continuous maps into itself) could have at most finitely many isolated points. Indeed, we could use the identity map on the subset of non-isolated points, and we could send each isolated point to any point we want, and if there were infinitely many isolated points then we get at least $\mathfrak c=2^{\aleph_0}$ many continuous maps. Well, I take this back, as it is not obvious why the resulting maps need to be continuous, it may not be that easy to see, though the idea seems plausible.
On the other hand, if we have a strongly rigid example $X$ then $X$ cannot have any isolated point (for if $p$ was isolated then we could take the identity on $X\setminus\{p\}$, and send $p$ to any $x\not=p$ to obtain a continuous map that is neither the identity, nor constant).
I am thinking along the lines of starting with a strongly rigid example $X$ and adding an isolated point $p$ to get a space $Y=X\cup\{p\}$ that is not strongly rigid yet has only countably many continuous maps into itself. This (or more generally, adding finitely many isolated points) was supposed to be easy, but I am all getting messed up with the details, and starting to doubt it (watching US Open tennis men's final at the same time, and that is actually over now, but let me leave this question alone for a moment).