number theory functions and stuff