Generalization of Beatty's Theorem