Quantified nouns in Arabic have a different grammatical case depending on the number that quantifies them.
Unlike all other numbers, the numbers 1 and 2 come after the noun they quantify. This is because singular and dual nouns are already conjugated to indicate the number, so the number is not necessary to convey the meaning. It’s added for emphasis, and is treated as a صفة (adjective). As such, it takes the case of the noun that it modifies, whether that’s the nominative, accusative, or genitive case.
The noun takes the case of its position in the sentence, such as nominative case if it’s a subject, accusative case if it’s the direct object, etc.
The numbers 3 to 10 come before the noun they quantify and make up an إضافة (idhaafa construction) along with it. Note that while إضافة is often thought of as a possessive construction, its real function is that the مضاف إليه (second word of the إضافة) answers the question من or ماذا raised by the مضاف (first word of the إضافة).
Because of this, إضافة is used for numbers, with the number being the مضاف and the quantified noun the مضاف إليه and is therefore in the genitive case.
The numbers 20 to 99 come before the noun they quantify, but they do not make up an إضافة. Instead, the noun that follows them is treated as a تمييز (tamyeez). The word تمييز literally means “to give someone/something special treatment”, “to make it stand out”. Grammatically, it’s a kind of determiner. For example, look at the following sentence:
البنت أكثر الطلاب اجتهادًا
This sentence literally translates to, “The girl is the most among the students in studiousness.” So when you say البنت أكثر الطلاب, you have to ask, أكثر الطلاب في ماذا؟, and the answer is the تمييز, which determines what she is the most among the students in: اجتهادًا.
A تمييز can be rephrased as an اضافة. In our example, it can be rewritten as اجتهاد البنت. In other words, a تمييز serves a similar function as an اضافة.
You’re now probably wondering why the noun that follows numbers between 20 to 99 are treated as a تمييز rather than as a مضاف إليه. The answer is that the endings of these numbers resemble the sound masculine plural suffixes ون and ين. For example, 20 is عشرون or عشرين, and 90 is تسعون or تسعين. This means that if they were to take the function of the مضاف, the ن at the end would have to be omitted, as is the case with the sound masculine plural. However, because the ن is part of the word itself and not an added suffix, this cannot happen. To avoid this dilemma, the noun is treated as a تمييز and is therefore in the accusative case.
Let’s now go back to 11–19. These numbers are undeclined. This is because they used to have the same structure as 21 to 99. For example, 19 used to be تسعةٌ وعشرٌ. However, these numbers became fixed with a فتحة at the end of each word: تسعةَ عشرَ. When a word becomes fixed, it becomes undeclined (similar to particles and pronouns). The و became implied.
Because they became fixed, it is said that the tanween became implied as well. As such, the noun that follows them cannot be a مضاف إليه (a مضاف cannot have a tanween), and is instead treated as a تمييز and is therefore in the accusative case.
تسعةَ عشرَ كتابًا
Multiples of 10, 100, 1,000, etc:
These numbers are treated as the default, which is as a مضاف, with the noun that they quantify taking the position of the مضاف إليه, as we saw with the numbers 3–10.