  It is still open whether there exist infinitely many Fermat primes or
infinitely many composite Fermat numbers. The same question concerning the
Mersenne numbers is also unsolved. Extending some results from [9], we
characterizethe the Fermat primes and the Mersenne primes in terms of
topological minimality of some matrix groups. This is done by showing, among
other things, that if $\Bbb{F}$ is a subfield of a local field of
characteristic $\neq 2,$ then the special upper triangular group
$\operatorname{ST^+}(n,\Bbb{F})$ is minimal precisely when the special linear
group $\operatorname{SL}(n,\Bbb{F})$ is. We provide criteria for the minimality
(and total minimality) of $\operatorname{SL}(n,\Bbb{F})$ and
$\operatorname{ST^+}(n,\Bbb{F}),$ where $\Bbb{F}$ is a subfield of $\Bbb{C}.$
  Let $\mathcal F_\pi$ and $\mathcal F_c $ be the set of Fermat primes and the
set of composite Fermat numbers, respectively. As our main result, we prove
that the following conditions are equivalent for $\mathcal{A}\in \{\mathcal
F_\pi, \mathcal F_c\}:$
  $\bullet \ \mathcal{A}$ is finite;
  $\bullet \ \prod_{F_n\in \mathcal{A}}\operatorname{SL}(F_n-1, \Bbb{Q}(i))$ is
minimal, where $\Bbb{Q}(i)$ is the Gaussian rational field;
  $\bullet \ \prod_{F_n\in \mathcal{A}}\operatorname{ST^+}(F_n-1, \Bbb{Q}(i))$
is minimal.
  Similarly, denote by $\mathcal M_\pi$ and $\mathcal M_c $ the set of Mersenne
primes and the set of composite Mersenne numbers, respectively, and let
$\mathcal{B}\in\{ \mathcal M_\pi, \mathcal M_c\}.$ Then the following
conditions are equivalent:
  $\bullet \ \mathcal B$ is finite;
  $\bullet \ \prod_{M_p\in \mathcal{B}}\operatorname{SL}(M_p+1, \Bbb{Q}(i))$ is
minimal;
  $\bullet \ \prod_{M_p\in \mathcal{B}}\operatorname{ST^+}(M_p+1, \Bbb{Q}(i))$
is minimal.
