This is a very common programming interview question :)