Under normal circumstances, the chance of escaping is determined by the formula:
>![Bulbapedia/ Escape Formula]
- A is the current Speed of the player's active Pokémon,
- B is the opposing Pokémon's Speed divided by 4, mod 256, and
- C is the number of times the player has tried to escape during the battle (counting
the current attempt).
- If F is greater than 255, the player escapes automatically. Otherwise, a random number is generated between 0 and 255. If that number is less than F, the player escapes. If not, the escape fails and the player's Pokémon does not make a move that turn.
Several other conditions can cause escape to always succeed or always
- An opponent Pokémon with the ability Shadow Tag causes the player's escape attempts to fail if the player's Pokémon does not also have Shadow Tag.
- An opponent Pokémon with the ability Arena Trap causes the player's escape attempts to fail if the player's Pokémon is not Flying-type or levitating.
- The reusable held item Smoke Ball causes its holder's escape attempts from wild Pokémon to succeed. The items Poké Doll, Fluffy Tail, and Poké Toy can be used to escape from wild Pokémon.
- Trapping moves used by the opponent can prevent the player from even making escape attempts.
- If the player's Pokémon is under the effect of Ingrain, it will be unable to escape.
- The ability Run Away causes escape attempts to succeed and ignores anything above that would prevent escape. This applies even if the user of Run Away has fainted.
- While not effects that directly affect escape, using the moves Whirlwind or Roar in a wild battle forces the wild Pokémon to leave the battle, which has the same effect as escaping. However, if the wild Pokémon has the ability Suction Cups or has used the move Ingrain previously in the battle, it will be immune to Whirlwind and Roar. Similarly, a Pokémon that has the ability Soundproof is immune to Roar.
Click on the link and look at the Example:
Source: [Bulbapedia/ Escape]