# Grammar for language L on {a, b} where L = {w|na(w)mod 3 = 0} [duplicate]

I am able to form the regular expression but I am not confident with the grammar. I have tried the following:

S-->aaaS|bS|b|lambda

Regular expression is given by:

b* +(ab*ab*ab*)*


Somebody please guide me.

Zulfi.

• How to convert a regular expression to a CFG. Your question might be better if you include the regular expression which you think answers the assignment. – rici Dec 3 '19 at 3:09
• Please edit the question instead of adding details in a comment. As you can see, formatting characters often make comments unreadable. Anyway, that regular expression is (probably) correct or almost correct but the CFG in your question is quite different. See the link in my previous comment. – rici Dec 3 '19 at 4:16
• Sorry, this is not CFG question: Give a regular expression for L on Σ ={a,b},where L={w|na(w) mod 3=0}. – user2994783 Dec 3 '19 at 4:25
• Its not an assignment, its exam preparation. – user2994783 Dec 3 '19 at 4:43
• Descriptions of how to convert a regular expression to a NFA are well-documented, as are descriptions of how to convert automata to a grammar. This should be in any decent textbook. It's also easy to convert a grammar to a grammar directly – D.W. Dec 3 '19 at 6:12