in reply to Calculate propabilities without recursion? Coin toss.
That's a very naïve implementation. You calculate n! a total of (n-k+1) times. You calculate 0.5x * 0.5n-x just as many times even though it's always equal to 0.5n. At the very least, doing some simple math legwork first would go a long way.