Escape
In the main series Pokémon games, it is possible to escape from a battle against a wild Pokémon by selecting "Run" on the main battle screen. It isn't possible to run from a trainer battle or if the opposing Pokémon has the ability Arena Trap or Shadow Tag.
The chance of escaping is determined by the formula , where
A is the current Speed of the player's active Pokémon.
B is the opposing Pokémon's Speed divided by 4 mod 255.
C is the number of times the player has already tried to escape during the battle.
If F is greater than 255, the player escapes automatically. Otherwise, a random number is generated from 0-255. If that number is less or equal to F, the player escapes. If not, the escape fails.
Example
The player's Pokémon has a Speed of 25 and the wild Pokémon has a Speed of 100. The player tries to escape, but hasn't attempted to flee anytime earlier in the battle.
First, calculate B:
Then, calculate F:
Since F isn't above 255, generate a random number between 0 and 255.
The probability of escaping is , or approximately 25%.