# Generate all the Lyndon words of length 5 over the alphabet
# {1,2}
LyndonW(5)
# or equivalently
LyndonW(5,2)
# The previous result in a compact form
LyndonW(5,2,TRUE)
# Generate all the Lyndon words of length 5 over the alphabet
# {0,1}
LyndonW(5,2,TRUE,0)
Run the code above in your browser using DataLab