Stop saying 1 is prime, and it's perfect.
EDIT: There are some interesting design decisions here. In particular, even & odd powers of 2 are handled differently.