Calculation of needed test size for accurate prediction

#1
Hi all,

During my bachelors degree (ecology), I remember learning how to do a statistical test that lets me calculate the necessary sample size to statistically prove the difference between two possible outcomes. Right now I want to experimentally find the chance of something to be either True or False, and test the difference between two predicted chance values.
In the first example I want to find the difference between two predicted chance values, 51% and 52% chance. I want to test with a 5% error margin, and I want to know approximately how many tests I need to perform to be able to conclude whether the True chance is 51% or 52%. After that I want to do the same with other True and False-values (53% and 56%, 20% and 22%, and others).
I can use the statistical programs R and SPSS, but I prefer the former.

So my question: What is the name of this statistical test? How can I calculate the nessecary sample size in which I can conclude that either one is correct? And what would be a code example for this test?

Best regards,
Lukas (a Master's student in biology)