I don't know the math but I just google for mining calculator on google and it solves the issue.I recommend you do the same rather than sharpening up your mind
LoLz... I'm writing the code for a mining calculator, so needed the formula.
This would actually be a good way to test your program. If you were to input a certain hashrate into the website, the 24 hour BTC mined amount should be the same on your program.
The website that I used was
http://www.bitcoinx.com/profit/ (site contains an ad, but I am not affiliated with them).