Microsoft interview question

Typical programming questions, (math-oriented).