I decided to try my hand at the Stanford’s AI Class. The pre-requisites mentioned Probability and Linear Algebra. So I started watching Probability videos on KhanAcademy.

Sal Khan was teaching how to find the probability of 2 heads when you toss a coin 5 times.

A classic nCk problem:

The probability of getting 2 heads while tossing a coin 5 times is:

But I wanted to find out the probability of getting at least 2 heads when I toss 5 coins. Its really simple. All I had to do is P(2) + P(3) + P(4) + P(5). But then computing by hand (or a calculator) was painfully slow, let alone do it 4 times. So I wrote two little functions in Python that will calculate factorial (yes I reinvented the wheel) and

**Nothing teaches you math faster than trying to write a program to do the math for you.**
Writing a program is the same as teaching the computer how to do a certain task. The only way you can teach someone to do a task is to become a master at doing that task yourself.

Bonus: It also teaches you corner cases like 0! = 1 and that you wouldn’t think of otherwise.