Instructions
Trade Pokemon with other players often. The ID number of a Pokemon is based partially on the ID number for the player and partially on the Pokemon's type. Trading with other players gets you Pokemon with ID numbers based on players other than yourself, increasing your chance of a partial match.
Visit Lilycove and go to the counter where the girl draws the lotto tickets. Don't talk to her yet. Save the game with your character standing right in front of her. Shut down your game and wait until the next day according to the game's internal clock; if you set the clock to your local time when you started playing, it should roll over to the next day at midnight.
Turn on the game after a day has passed and talk to the lotto girl. If you win the lottery drawing, collect your prize and continue playing the game. If you don't win, turn off the game without saving and turn it back on to start playing again. Because the game recognizes that it's a different day than the date of the save, it will generate another random lotto number instead of using the one that it drew the first time.
Continue resetting the game until one of your Pokemon matches the lotto drawing number. If you match two digits you'll receive a "PP Share" item, if you match three digits you'll get an "Exp Share" item, and if you match four digits you'll win a "Max Revive" item. If you match all five digits you'll win a "Master Ball" item.