## Urinal Numbers

The unwritten rules of going to the urinal are that if you are the first one in the bathroom you take one of the ones at either end. Then each new person joining maximises their distance from all the others when picking theirs. Nobody is comfortable using the urinal next to someone else, so typically a barrier of one unused toilet is required. For example, if their are 5 urinals then person 1 could stand at urinal 1, person 2 would then go to urinal 5 and person 3 would then maximise their distance from both by taking urinal 3. No other people could comfortably use that bathroom, so 5 urinals have a capacity of 3 people.

However there is an odd quirk of these rules which leads, through completely rational behaviour, to less than the optimum capacity for some number of toilets. Imagine we have a bathroom with 7 urinals. Ideally we would be aiming for numbers 1, 3, 5 and 7 to be used for maximum capacity. However, as people file into the bathroom, person 1 takes urinal 1, person 2 urinal 7 and person 3 maximises their distance by taking number 4. This leaves nobody in 2, 3, 5 or 6.

When designing a bathroom you should aim to have a number of urinals where people’s natural tendencies to spread themselves out leads to them occupying all of the odd numbered urinals. These numbers we call urinal numbers and they begin: 1, 3, 5, 9, 17… Apart from the first, each of these are of the form 2^{n}+1. Here is a closed form for the number of urinals used for the number of urinals n in the bathroom: f(x) = 1 + 2^{floor(ln(n-2)-1)} + max(0, n - 1 - 1.5*2^{floor(ln(n-2)-1)})