Have a look here: Divisibility rule - Wikipedia, the free encyclopedia
Have a look here: Divisibility rule - Wikipedia, the free encyclopedia
Yes, this is quite interesting but I guess the rules for bigger prime numbers just get messy and heavy (for 17, subtract 5 times the last digit from the rest ...).
Maybe you might like to consider working in particular bases and applying basewise division (that is, a division that is made trivial due to the base used). Although base conversion is not the easiest thing to do