Chance of a Specific Sum for N Dice

Published by Gabberson in

Given the number of dice and the sum we want to get the chance of, return the chance rounded to 2 decimals, formatted as shown (with the % at the end).

Examples

chance(3, 6) ➞ "4.63%"
# There is approximately 4.63% chance for rolling 6 with 3 dice.

chance(5, 20) ➞ "8.37%"

chance(2, 7) ➞ "16.67%"

Notes

N/A

Watch a quick demo on how Edabit works.