How to simulate polyhedral dice in Minecraft? [duplicate]

You need to create a counter that resets after n ticks, where n is the number of sides on your dice. You can see an overview of creating a counter on Wikipedia. All you need to do is add extra logic so that when the output matches n, it resets the counter to 0.

Hook up your counter to a fast clock with a switch to stop the clock to simulate rolling the dice. The number rolled will be displayed in binary.