Suppose we have $10$ observations and we run $20$ trials. A two-sided binomial test with $H_0:p=0.4$ from R I get is
binom.test(x=10, n = 20, p = 0.4, alternative = c("two.sided"))
Exact binomial test
data: 10 and 20
number of successes = 10, number of trials = 20, p-value = 0.3703
alternative hypothesis: true probability of success is not equal to 0.4
95 percent confidence interval:
0.2719578 0.7280422
sample estimates:
probability of success
0.5
if I assume $H_0:p=0.3$, I get
Exact binomial test
data: 10 and 20
number of successes = 10, number of trials = 20, p-value = 0.08345
alternative hypothesis: true probability of success is not equal to 0.3
95 percent confidence interval:
0.2719578 0.7280422
sample estimates:
probability of success
0.5
The confidence intervals in both cases are identical. I believe that is because of a same number of observations. I found this article about the confidence intervals. But it doesn't tell me how to find k and both lower bound and upper bound.