I will give a short trick for divisibility: |w| i.e length of string is divisible by a,b.
If a doesn't divide b and b doesn't divide a then Min. states = a*b
Case 1 : Divisible by a and b ----> If a divides b or b divides a then Min. No .of states = LCM(a,b)
Case 2: Divisible by a or b ------> If a divides b or b divides a then Min. states = GCD(a,b)