Universal Change Number (UCN) Decoder

Decode a UCN to a Row of Bells

This is a step by step walk through the process of converting a Universal Change Number into a row of bells manually. A computer function will follow the same process.
1) The first step is to write down the factorial column value under each column, from left to right. These are 0, 1, 2, 6, 24, 120 for six bells adding 720 & 5040 when eight bells are expected. Keep a note of the current UCN value as it decreases. Under the column heading write down the bells in rounds to prefill the first row in the grid.
2) Working from right to left. If the remaining UCN we are trying to decode is smaller than the factorial column value. Leave the bell in that column where it is. Move to the next column on the left and repeat this stage.
3) Divide the remaining UCN by the column factorial value. Note how many times it can be divided. The remainder will be used in the next iteration of Step 2.
4) Using the result of the division, subtract that number from the column's place bell number. The result of the subtraction is another column, the offset column. Now swap over the bells in the column we are examining and the offset column.
5) If the UCN remaining is not zero, move to the next leftward column and repeat from Step 2. If the UCN is 0, then stop. The row now contains the bells in the order prescribed by the UCN.

To see this process in action click on the button below. As an example enter the UCN 24 to see how iteration halts when the value reduces to zero. Try a UCN of 6951 to process all the place bells.

Calculation Details