Russian roulette
It's Russian roulette! The rules are simple. Shoot a revolver with n
slots for bullets and one round inside at your head and you might not die!
This Question is different from other Russian roulette questions because it takes input to change the chance of exiting with an error.
Task:
Make a program that takes integer n
(you can assume that 10<=n<=128) as input and outputs nothing.
but how do I tell if I'm dead?
The program generates a random number x in the range 0 - n inclusive. If x=0 the revolver fires and the program exits with an error (you die). Otherwise the program exits normally.
If your language needs it, the range can be 1-n inclusive.
Standard loopholes forbidden, etc. Upvote answers in fun languages! What I'd really like to see is an answer in a language that doesn't have normal randomness (eg. in Befunge where ?
sends you in a random direction instead of giving a random number).