Gapplet

The elements of the dihedral group Dn can all be written in the form ciaj. You can try this out by inputting the number n and a word in a and c.

Input a natural number n, e.g., 
  5.
 
Input a word in "a" and "c", e.g., 
"acacaacccaaaccc" 
 
Rewrite this word as an element of Dn.