All,

I am sure this is neither the first nor last time this has been discussed, but I thought I would offer my efforts to solve this problem. Since it involves some math symbols I'll just put a link here. Any constructive feedback is welcome.

See Here

Edit :: Changed the last equation to be what it should be from the previous steps. Changed 'floor' function to 'ceiling' because I was tired and buzzed when I wrote the original draft. This doesn't change the logic, just makes the right number of dice needed for a glitch with odd numbers.