The article on the "Reliability of microbial sampling in assuring food safety and calculation of prevalence following negative tests" at

https://www.dairyscience.info/index.php/food-model/275-sampling.html has several calculators one of which calculates the number of samples required to meet a microbiological specification. The author has made the code for this calculator freely available. The code can be downloaded at https://www.dairyscience.info/index.php/202-uncategorised-sp-269/378-asp-code.html .