The phrase the number of requires a singular verb. The phrase a number of requires a plural verb.
Consider the following sentences, both of which are grammatically correct:
The number of frogs in the pond is twice the number of fish.
A number of protestors are gathering outside the capitol building today.
The number refers to a specific but unspecified number, and takes a singular verb. A number of is an idiom that simply means “several” and takes a plural verb.
When you see either phrase – “the number of” or “a number of” – disregard the number of the noun following it because that noun will always be plural. To ensure that you don’t mistake the noun inside the prepositional phrase for the subject, always cross out prepositional phrases:
The noun following the number of does not impact the verb because the subject of the sentence is number, which is singular. The noun following a number of will always be plural, because a number of means “several.”
A quick summary of how to recognize subject-verb agreement errors. Look for …
A subject and verb separated by a superfluous phrase set off by commas (“the sandwich”), a prepositional phrase, or an adjectival phrase (“filler phrases”).
Collective nouns like majority, audience, family…
Other confusing nouns like data/datum (data, often misused as a singular noun, is the plural of datum).
Separation by conjunctions such as “and,” “nor,” or “neither.”