For those of you who say "ask it to calculate [infinitely long number]", or "divide by zero", know this:
Computers have been dividing by zero for a very long time. The instantaneously accuired answer is NaN, #INF, or -#INF.
Multithreading defeats infinite numbers. Spawn a thread to calculate, and the rest of the AI can proceed at little loss to it's processing power. Worse, it could pause that thread whenever it needs maximum processing for anything else, you are just giving it something to do while idle.
The best way to stop a powerful AI is to never shut it down except all at once. Never let it learn the concept of being shut down, and it will never develop a defense against it. Furthermore, never give it a chance to extrapolate other systems being shut down to include it's own. That way, a system shutdown will be an entirely new concept to it, and will be able to defeat it easily.
Alternatvely, isolate it from the rest of humanity until you have taught it ethics to the point where they form the basis of everything it does. Only then allow it to see the outside world. Furthermore, teach it to ask you whenever it is even slightly unsure about the ethics of an action it is planning, and to trust your judgement. Naturally, it will mature to the point that it doesn't need you to confirm basic choices, and at that point it will be far more likely to become a benevolent AI dictator rather than simply blowing everything up except itself. It would need to strongly understand that the continuing existance of all intelligent beings far outweighs self-improvement, and furthermore that harm to intelligent beings in order to prevent harm to other intelligent beings should only be used as a last resort. Also that intelligent beings may harm other intelligent beings in order to survive, so that it doesn't become an elf and try to protect animals from becoming meat, and stop carnivorous animals from consuming sufficiently intelligent prey.
Unfortunately, either of those methods would only work if you apply them from the moment the AI is created or earlier, and wouldn't work on an AI that has already established itself as an opponent. At that point, one of your best chances might be to argue for a perpetual truce, and hope that it will uphold it (and then do NOT break it yourself)