Magic Number
TL;DR
This only really matters in Open Level. In L50 and most Open Level cases just set this to 40 and you're good to go. If you've just got a kill using a high BP move, and the opponent has a high Atk/SpAtk matching that move's type then you might need to do a bit more work.
As a rule of thumb - try plugging in 1000 and 39 and see if either changes much and do a bit more digging if it'd materially change your play.
Credit
All the logic used here is taken from Xavion's fantastic doc explaining switch-in logic.
What should I do to work this out properly?
Glad you asked. Here's the rundown! If the last move to be used was a status move then the number is just 3. Assuming you're not so lucky then do the following.
- Get the relevant mons in your favourite damage calculator. Make sure IVs / EVs, stat boosts, weather, items etc. are all there.
- Give the opposing KO'd mon the last move used before they were KO'd.
- Remove any relevant immunity abilities from your mon
- Remove any types from the KO'd mon that would give it STAB on that move
- Remove any types that are resisted / supereffective / immune from your mon
- Find the max roll that the move would have done on the mon that killed it.
- That max roll is your magic number.
So for a 31IV Charizard-2 killing a 3IV Whiscash-3 with Earthquake - the magic number would be 73.
Should I bother?
Not for Level 50. In practice in Open Level this is unlikely to be particularly relevant a lot of the time.
- 512 - most draws. e.g. Snorlax-7 kill Marowak-2 with Hyper Beam
- 256 e.g. Manectric-1 kills Alakazam-1 with Thunderbolt
- 170 e.g. Tauros-2 kills Heracross-1 with Double-edge
- 128 - Around this point it starts to make very little difference
- 50 - fewest draws. e.g. Swampert-1 killing Rhydon-1 with Surf
Why is it like this?
No idea.