The mathematical formula for w=6, b=4, d=7 and bet=1 would be
( 7 ) 1 6 ( 7 ) 0 7 ( 1 ) * (.6) * (.4) + ( 0 ) * (.6) * (.4)You can check your results by comparing them with what the executable ~jmache/cs1/Bino.class gets.
In order to achieve modularity and simplicity, I urge you to use several methods (program and test them one by one), probably in the following way:
main |* binomial / | \ choose pow pow / | \ factorial fa. factorial