what sample size is necessary for 95% CI? 
My take:
FOR a)
$n=10,$ UCB = $95$%, then $z_{\alpha/2}$ $= 1.645$
as we denote $p = 0.1 = w$, using $$n = \frac{\frac{z^2_{\alpha/2}}{2} - z^2_{\alpha/2}w^2 + \sqrt {z^4_{\alpha/2}(0.25-w^2)+w^2z^4_{\alpha/2}}}{w^2}$$ $$n = 380.3 = 381$$
FOR b)
I've treid $p = \frac{2}3 =w$, and use same formula as above, but I am not getting an answer I'm supposed to get, which is 339... what did I do wrong?
 A: I have not seen this formula for $n$ before. I suppose it is based
on the Wilson confidence interval for success probability $p = P(S).$
If you want a 95% CI, then it seems to me you need to use $k = z_{\alpha/2} = 1.96,$ where $k$ is my abbreviation. Also, in your first computation, I think you mean to set $w = .1$ (not $p = .1$, because you assume $p = 1/2$.) And I am puzzled why you set $n = 10,$ when
$n$ is what you're trying to find. Finally, I think $0.25$ in your
equation is $p(1-p) = pq = (1/2)(1/2) = 0.25.$  With all of that,
I do get the same result that you report from the following 
computation in R.
 k = 1.96; p = .5; q = .5; w = .1
 (k^2/2 - k^2*w^2 + sqrt(k^4 *(p*q - w^2) +w^2*k^4))/w^2
 ## 380.3184

The rationale for taking $p = q = 1/2$ when $p$ is unknown is that
this maximizes the required $n$ and thus insures it is large
enough for other possible values of $p$.
However, I do not get $n = 339$ when I change the problem so that
$p = 2/3$ and $q = 1/3$. (I'm not sure whether this is the change you
made, but it seems reasonable to me.) This should take care of
situations where the true $p$ is 2/3 or greater. Here is what I did get:
 k = 1.96; p = 2/3; q = 1/3; w = .1
 (k^2/2 - k^2*w^2 + sqrt(k^4 *(p*q - w^2) +w^2*k^4))/w^2
 ## 369.3332

Because you have what I take to be several typos in your Question,
I don't know where to go from here to help you resolve the
discrepancy. Please proofread everything (your Question and my Answer), and make any edits, suggestions,
or explanations that might help make the next attempt to help more
successful. 
Note: The traditional Wald CI for $p$ yields the equation
$n \approx 4k^2pq/w^2.$ Particularly for small $n$, this formula is
known not to be very good. Nevertheless, it is widely used by
public opinion pollsters, who normally deal with sufficiently
large $n$ that the formula is considered a reasonable guide.
For your part (a) it gives $n = 385$, and for part (b) $n = 342$.
These are the answers I would have given if you had not
supplied a formula of your own. They are not terribly far from
the answers you anticipated with your formula.
 k = 1.96; p = 1/2; q  = 1/2; w = .1
 4*k^2*p*q/w^2
 ## 384.16
 k = 1.96; p = 2/3; q  = 1/3; w = .1
 4*k^2*p*q/w^2
 ## 341.4756

Of course, any formula based on probability theory can deal only
with margins of error due to chance errors inherent in random sampling. Larger survey errors often have to do with the difficulties
of getting a random sample from the target population and getting straightforward answers to
questions.
