标签: bnf
如何以BNF形式写出奇数?
答案 0 :(得分:0)
你必须分别定义奇数位。
odd ::= "1","3","5","7","9"
然后定义一个包含所有数字的组
digit ::= odd, "2","4","6","8","0"
最后,将奇数定义为任意数字的数字,以奇数结尾使用递归
number ::= number digit | digit oddnumber ::= number odd | odd