101 views

Consider input alphabet $\Sigma = \{0,1,2,3,4,5,6,7,8,9\}$ and set of Non-Terminals as $\{A,B,C\}$

Assuming grammar is for positive odd integers upto 999.

So, grammar is:

$A \rightarrow CB1\ | \ CB3 \ | \ CB5 \ | \ CB7\ | \ CB9$

$B \rightarrow 0 \ | \ 1 \ | \ 2 \ | \ 3 \ | \ 4 \ | \ 5 \ | \ 6 \ | \ 7 \ | \ 8 \ | \ 9$

$C \rightarrow 0 \ | \ 1 \ | \ 2 \ | \ 3 \ | \ 4 \ | \ 5 \ | \ 6 \ | \ 7 \ | \ 8 \ | \ 9$

Edit: As Arjun sir has mentioned below, B and C are same. So, we can also write it as:

$A \rightarrow BB1\ | \ BB3 \ | \ BB5 \ | \ BB7\ | \ BB9$

$B \rightarrow 0 \ | \ 1 \ | \ 2 \ | \ 3 \ | \ 4 \ | \ 5 \ | \ 6 \ | \ 7 \ | \ 8 \ | \ 9$

B and C are the same right?
Yes. I forgot this thing. Thank you.