Constructing the grammar


#1

construct a grammar accepting
L={w ∈ {a,b}* | the number of a’s in w is divisible by 3}.


#2

E1-> aE2 | bE1 | @
E2-> aE3 | bE2
E3-> aE1 | bE3

here, @ symbolises empty.


#3