Expected die rolls to target
Your task
You repeatedly roll a fair k-sided die (faces 1..k) and accumulate the sum. You stop the moment the running total is >= target. Return the expected number of rolls, rounded to 6 decimal places. 1 <= k <= 20, 0 <= target <= 1000.
Examples
expected_rolls(k: int, target: int) -> floatExample 1
Input
expected_rolls(6, 1)Output
1