I need to find a grammar where $w\in A^*$, where $w$ consists of $n$ $a$'s followed by $n$ $b$'s, where $n\in\mathbb N$.
I came up with the rules $$ \begin{align} S&\to aSb\\ S&\to ab\\ S&\to \epsilon \end{align} $$
Is this the right way?
I need to find a grammar where $w\in A^*$, where $w$ consists of $n$ $a$'s followed by $n$ $b$'s, where $n\in\mathbb N$.
I came up with the rules $$ \begin{align} S&\to aSb\\ S&\to ab\\ S&\to \epsilon \end{align} $$
Is this the right way?
More minimal
will do. $ab$ is then a two-step derivation. But yours is fine too, minus the typo and lack of MathJax. Replace the 2 by
if a natural number in your definition is $\ge 1$ or not.