The Lottery is a daily activity that can be engaged in in all main series games, except the Generation I and Generation V games.
After pulling a lottery ticket, it checks the 5-digit number on it. If it matches from right to left any of the ID of the Pokémon, you win a Master Ball. Getting a match of 4 or less gives you a lesser prize and getting no matches gives you nothing. For example, if one of your Pokémon's ID is 12345 and the lottery ticket is 12345, you get a Master Ball. If the lottery ticket says, 62345, you get a 3rd prize which is a lesser prize than a Master Ball. Getting 54321, however, gets you nothing, despite the 3 in both numbers matching.
Prizes (Diamond and Pearl)[]
All match: Master Ball
Last 3: Exp. Share
Last 2: ?
Last 1: Backdrop