You can derive this formula by creating a hedged portfolio which will have a fixed value at t=1.
For example, if we have a portfolio of call and delta stocks then the initial value of portfolio at t=0: C0 - (Delta)S0
At t=1, for up move value of portfolio: C+ - (Delta)S+
At t= 1, for down move value of portfolio: C- - (Delta)S-
if the portfolio has same value in up move and down move then:
C+ - (Delta)S+ = C- - (Delta)S-
=> Delta = (C+ - C-)/(S+ - S-)
Since we have removed any uncertainty regarding the value of portfolio in future the present value of the portfolio should be equal to cost of setting up the portfolio.
so, C0 - (Delta)S0 = (C+ - (Delta)S+)/(1 + rf) —–1
Now, Delta = (C+ - C-)/(S+ - S-) or (C+ - C-)/((u - d)*S0)
and S+ = u*So
relacing the above in equation - 1,
we get C0 - (C+ - C-)/(u - d) = (C+ - u*(C+ - C-)/(u - d))/(1 + rf)
Solve the above equation, you will get something like:
C0 = (Cu*(1 + rf -d)/(u-d) + Cd*(u - 1 -rf)/(u-d))/(1 + rf)
(1 + rf -d)/(u-d) = risk neutral probablity = p
(u - 1 -rf)/(u-d) = 1 - p