Simple arithmetic. If you hold 100 shares of 100,000 outstanding shares, you own 0.1% of the company. If they buy back 5000 shares and you sell 5 shares, you still own 95 shares of 95,000 outstanding shares (0.1% of the company) + cash.
That's exactly what a dividend would do.
Silverlake is correct to point out that this doesn't apply to small investors, however.