for (a) and (b) you can easily use the modulo operator
e.g. to test whether it is a multiple of 7: (x%7)==0
e.g. to test even/odd: (x%2)

Pieter