move some shared logic to functions
indent the proper amount
don't do value checks in the numbers
Merge pull request #1125 from reaperhulk/rsa-numbers-with-functions

Move some shared logic to functions