Program to construct a DFA which accepts the language L = { aN | N â ‰¥ 1 } | Function to check whether the String S satisfy the given DFA or not ; Stores the count of characters ; Iterate over the range [ 0 , N ] ; Count and check every element for ' a ' ; If String matches with DFA ; If not matches ; Driver Code ; Function Call
function isAcceptedDFA ( s , N ) { var count = 0 ; for ( var i = 0 ; i < N ; i ++ ) { if ( s [ i ] === " " ) count ++ ; } if ( count === N && count !== 0 ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } var S = " " ; isAcceptedDFA ( S , S . length ) ;