The math (or maths, depending on your continent) is pretty short and simple, but as long as your voltage is 5V or less I usually start with a value around 300 ohms as a guess. However, I'm somewhat lazy and have found an iPhone app that takes all the bother out of this - it's Adafruit's Circuit Playground. Specify the color of your LED, your voltage, what current you want (usually less than 20 mA), and it will tell you the exact resistor value and the closest "standard", easy-to-find resistor size.
As for the math, it's
R = (Vsupply - Vled) / I
where Vsupply is your project's supply voltage (frequently 3.3V or 5V),
Vled is the voltage drop across the led (somewhere around 2.1V depending on the color),
and I is the current you want (0.020 A is really bright, 0.002 A is pretty dim)
If you are using a voltage higher than 5V you probably need a larger resistor.