Say you had started with 3.75 taken out each pay period. After five such deductions you'd have exactly enough to buy an 18.75 bond. But suppose at some time when you happened to have 7.50 built up in your account you decided you wanted to get bonds more frequently and shifted to having 6.25 taken out each pay period so you'd get a bond every three pay periods. Next pay period you'd have 13.75 in your account, then next time you'd have $20, which is enough to get a bond and have 1.25 left over in your account, followed by a balance of 7.50 the next time, and this cycle would repeat forever, with your balance never going below 1.25. That 1.25 that hangs around in your balance is not helping you get your bond any sooner.
Devise an algorithm or formula so you can determine if such "dead money" is in a person's account, and how large that perpetually low balance is, based on a bond purchase price, the current balance, and the amount deducted each period, so that that lowest balance in the cycle can be refunded to the employee and the cycle will include a zero balance at some point.
Make sure your method allows for the fact that it may take a while before the balance goes to zero. The number given above were chosen to be simple, but allow for deduction amounts that may bear no simple relation to the purchase price.