Expected die rolls to target

Write codeMedium30 minCitadel style

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) -> float
Example 1
Inputexpected_rolls(6, 1)
Output1