Trial and Error – BERGER

The text box takes in whatever you input, and attempts to write it using initial segments of elements. It does so by finding the longest initial segment of your input that is an initial segment of an element, and then returning the atomic number of the first element with that as its initial segment, as well as the length of this initial segment; it then repeats, until all letters from the input are used, or it hits a letter not appearing at the beginning of elements (J, Q, W). The clue below is the result from inputting the correct answer, BERGER.