Here is the sentence:
Rapping the pencil on the edge of the desk, the fourth cause of the French
Revolution would not come to mind.
Good choice! You recognized that the modifier is dangling. Rapping the pencil on the edge of the desk, a participle phrase, has no target in the sentence to describe.
To fix the problem, you should revise the sentence like this: Rapping the pencil on the edge of the desk, Rodney could not remember the fourth cause of the French Revolution. Adding Rodney to the sentence lets the reader know who is having trouble with the exam.