EDIT: Just realized that the problem asks for the odds of being a billionaire, not f. So there are probably a good number of f that work, but they all produce the same odds.
P.S. I must apologize for abstractly referring to a solution approach as "this", but I didn't want to create a spoiler in case anyone else had felt inspired.
http://forum.projecteuler.net/viewtopic.php?f=50&t=1982
I don't see this problem listed, but I didn't look through the whole thread.
Solved it with pencil and paper, if "pencil and paper" includes asking Wolfram Alpha a few questions :)
For one coint toss, I get:
(previous winnings) x (1+f) if I win
(previous winnings) x (1-f) if I lose
Thus, w being the number of times I win, I get the total $$ we would have:
(1+f)^w x (1-f)^(1000-w)
But those cases are not equally likely, so we have to ponderate them with a normal law centered at 1000/2, variance at sqrt(1000/4):
(1/(sqrt(2xPi)xsqrt(250))) x exp(-(500-w)^2/500)
So, now we can take an f, calculate the number of w's that put us above 1B$, and sum up the ponderation for each case. Then find the right f that optimized the chance of being a billionaire. This chance is the solution.
You're using the normal approximation to the binomial distribution. It may or may not be a good enough approximation. Better to do the binomial thing exactly. This requires arbitrary-precision integer arithmetic, but that's pretty easily available.