R, 4139 bytes
functionn=scan(n)n*rgeom;n*rgeom(1,1-1/n)+sample(n-1,1)
Explanation: this solution avoids recursion/while loops by directly calculating the distribution of the number of explosions that will occur. Let \$n\$ be the number of sides on the die. If you denote success as rolling an \$n\$ and failure as rolling anything else, then you have probability \$\frac1n\$ of success. The total number of explosions is the number of successes before the first failure. This corresponds to a \$\mathrm{Geometric}\left(1-\frac{1}{n}\right)\$ distribution (see the wikipedia page, which defines success and failure the other way round). Each explosion brings \$n\$ to the total. The final roll follows a \$\mathrm{Uniform}(1,2,\ldots,n-1)\$ distribution which we add to the total.
R, 41 bytes
function(n)n*rgeom(1,1-1/n)+sample(n-1,1)
Explanation: this solution avoids recursion/while loops by directly calculating the distribution of the number of explosions that will occur. Let \$n\$ be the number of sides on the die. If you denote success as rolling an \$n\$ and failure as rolling anything else, then you have probability \$\frac1n\$ of success. The total number of explosions is the number of successes before the first failure. This corresponds to a \$\mathrm{Geometric}\left(1-\frac{1}{n}\right)\$ distribution (see the wikipedia page, which defines success and failure the other way round). Each explosion brings \$n\$ to the total. The final roll follows a \$\mathrm{Uniform}(1,2,\ldots,n-1)\$ distribution which we add to the total.
R, 39 bytes
n=scan();n*rgeom(1,1-1/n)+sample(n-1,1)
Explanation: this solution avoids recursion/while loops by directly calculating the distribution of the number of explosions that will occur. Let \$n\$ be the number of sides on the die. If you denote success as rolling an \$n\$ and failure as rolling anything else, then you have probability \$\frac1n\$ of success. The total number of explosions is the number of successes before the first failure. This corresponds to a \$\mathrm{Geometric}\left(1-\frac{1}{n}\right)\$ distribution (see the wikipedia page, which defines success and failure the other way round). Each explosion brings \$n\$ to the total. The final roll follows a \$\mathrm{Uniform}(1,2,\ldots,n-1)\$ distribution which we add to the total.
R, 41 bytes
function(n)n*rgeom(1,1-1/n)+sample(n-1,1)
Explanation: for a die withthis solution avoids recursion/while loops by directly calculating the distribution of the number of explosions that will occur. Let \$n\$ be the number of sides, on the die. If you denote success as rolling an \$n\$ and failure as rolling anything else, then you have probability \$\frac1n\$ of success. The total number of explosions followsis the number of successes before the first failure. This corresponds to a \$\mathrm{Geometric}\left(1-\frac{1}{n}\right)\$ distribution (number of successes beforesee the first failure, where probability of success is \1ドル-\frac1n\$)wikipedia page, which each bringdefines success and failure the other way round). Each explosion brings \$n\$ to the total. The final roll follows a \$\mathrm{Uniform}(1,2,\ldots,n-1)\$ distribution which we add to the total.
R, 41 bytes
function(n)n*rgeom(1,1-1/n)+sample(n-1,1)
Explanation: for a die with \$n\$ sides, the number of explosions follows a \$\mathrm{Geometric}\left(1-\frac{1}{n}\right)\$ distribution (number of successes before the first failure, where probability of success is \1ドル-\frac1n\$), which each bring \$n\$ to the total. The final roll follows a \$\mathrm{Uniform}(1,2,\ldots,n-1)\$ distribution which we add to the total.
R, 41 bytes
function(n)n*rgeom(1,1-1/n)+sample(n-1,1)
Explanation: this solution avoids recursion/while loops by directly calculating the distribution of the number of explosions that will occur. Let \$n\$ be the number of sides on the die. If you denote success as rolling an \$n\$ and failure as rolling anything else, then you have probability \$\frac1n\$ of success. The total number of explosions is the number of successes before the first failure. This corresponds to a \$\mathrm{Geometric}\left(1-\frac{1}{n}\right)\$ distribution (see the wikipedia page, which defines success and failure the other way round). Each explosion brings \$n\$ to the total. The final roll follows a \$\mathrm{Uniform}(1,2,\ldots,n-1)\$ distribution which we add to the total.
R, 41 bytes
function(n)n*rgeom(1,1-1/n)+sample(n-1,1)
Explanation: for a die with \$n\$ sides, the number of explosions follows a \$Geometric\left(1-\frac{1}{n}\right)\$\$\mathrm{Geometric}\left(1-\frac{1}{n}\right)\$ distribution (number of successes before the first failure, where probability of success is \1ドル-\frac1n\$), which each bring \$n\$ to the total. The final roll follows a \$Uniform(1,2,\ldots,n-1)\$\$\mathrm{Uniform}(1,2,\ldots,n-1)\$ distribution which we add to the total.
R, 41 bytes
function(n)n*rgeom(1,1-1/n)+sample(n-1,1)
Explanation: for a die with \$n\$ sides, the number of explosions follows a \$Geometric\left(1-\frac{1}{n}\right)\$ distribution (number of successes before the first failure, where probability of success is \1ドル-\frac1n\$), which each bring \$n\$ to the total. The final roll follows a \$Uniform(1,2,\ldots,n-1)\$ distribution which we add to the total.
R, 41 bytes
function(n)n*rgeom(1,1-1/n)+sample(n-1,1)
Explanation: for a die with \$n\$ sides, the number of explosions follows a \$\mathrm{Geometric}\left(1-\frac{1}{n}\right)\$ distribution (number of successes before the first failure, where probability of success is \1ドル-\frac1n\$), which each bring \$n\$ to the total. The final roll follows a \$\mathrm{Uniform}(1,2,\ldots,n-1)\$ distribution which we add to the total.