I got to wondering what would be the minimum number of at bats needed to have a specific batting average in baseball. For this purpose, consider batting average to be hits divided by at bats and rounded to 3 places. For example, a .271 average would be anything greater than or equal to .2705 but less than .2715. So what I would like to know is how many times would a player have to bat before it would be possible for him to have a .271 average. I need a general formula to calculate this minumum for any batting average. Something I could use in Excel would be a bonus. Thanks for any help.
Note: I have been able to get some answers to this problem using historical baseball statistics. As an example, since 1901, there have been over 200 instances of a player hitting .228. Seventeen of those had exactly 57 at bats, but none had fewer. So 57 appears to be the fewest at bats one can have to get a .228 batting average. Some others: .237 is 38 AB, .215 is 65 AB. This method is tedious and doesn't guarantee accuracy.