World's most popular travel blog for travel bloggers.

[Solved]: How to write this regular expression

, , No Comments
Problem Detail: 

Consider the language over the alphabet $\sum= \{a\}$ containing strings whose length is either a multiple of 2 or 3 (including the empty strings). Writing a regular expression for this language

Asked By : Leroy Kayanda

Answered By : Yuval Filmus

Hint: A number $n$ is a multiple of $2$ or $3$ if $n \; \mathrm{mod} \; 6 \in \{0,2,3,4\}$.

Simpler solution: Take the union of the words whose length is a multiple of 2 with the words whose length is a multiple of 3.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/28121

0 comments:

Post a Comment

Let us know your responses and feedback