  We prove that the number of indecomposable vector bundles of fixed rank r and
degree d over a smooth projective curve X defined over a finite field is given
by a polynomial (depending only on the pair (r,d) and the genus g of X) in the
Weil numbers of X. We provide a closed formula -expressed in terms of
generating series- for this polynomial. We also show that the same polynomial
computes the number of points of the moduli space of stable Higgs bundles of
rank r and degree d over X (at least for large characteristics). This entails a
closed formula for the Poincar\'e polynomial of the moduli spaces of stable
Higgs bundles over a compact Riemann surface, and hence also for the Poincar\'e
polynomials of the character varieties for the groups GL(r).
