There are two different things to distinguish. If a number counts something, than the number should be masculine or feminine. The something can be said explicitly in the sentence, or implicit from the context. Here they give an example of talking about the number of something masculine that is known in context.
Then, there are cases of using numbers as abstract, not counting something in particular. Then the feminine form is used.