Kirill Osenkov asked a simple interview question. As is usual with questions of its nature, many incorrect solutions were offered. Of those which were correct, one was incredibly slow while others were over complicated.
I have created a VS solution containing unit tests which exercise the given solutions, plus benchmarks for those which actually pass the tests.
You can find the solution on Google Code in the Kirill Question project.
Run the unit tests in the KirillQuestion project in order to see which implementations fail and where.
Set HS.Benchmark.Playground as startup project and run the solution in release mode in order to see the benchmark results.