This was the genie's thought process:
“During the first hundred years of my imprisonment, I swore that if any one should deliver me before the expiration of that period, I would make him rich, even after his death; but that century ran out, and nobody did me the good office. During the second, I made an oath that I would open all the treasures of the earth to any one that might set me at liberty; but with no better success. In the third, I promised to make my deliverer a potent monarch, and to grant him every day three requests, of what nature soever they might be; but this century passed as well as the two former, and I continued in prison. At last, being angry to find myself a prisoner so long, I swore that if afterward any one should deliver me, I would kill him without mercy, and grant him no favour but to choose the manner of his death; and, therefore, since thou hast delivered me to-day, I give thee that choice.”