In a while loop, update the value used by the condition on every pass. Check the starting state before counting the first step.
A download removes one full chunk at a time until a partial chunk remains.
remaining = 17
while remaining >= 5:
remaining -= 5
print(remaining) # 2The loop checks 17, 12, 7, and finally 2. At 2 it stops before another subtraction. Decide which battery levels still need another step.
Complete charge_steps(level, target, gain). Return the smallest number of equal charging steps needed to reach or exceed the target. Gain is a positive integer. An already charged battery needs zero steps.
charge_steps(20, 50, 12) # 3 (32, 44, 56)