Just out of curiosity, i've just been measuring some benchmarks by running the code 1000000 times and the results are as follows:
the code by
nelio took: 7 wallclock secs ( 6.73 usr + 0.02 sys = 6.75 CPU)
the code by
davorg took: 5 wallclock secs ( 4.90 usr + 0.01 sys = 4.91 CPU)
the code by
altblue took: 5 wallclock secs ( 5.05 usr + 0.01 sys = 5.06 CPU)
the code by
johngg took: 4 wallclock secs ( 2.99 usr + 0.01 sys = 3.00 CPU)
the code by
andyford took: 6 wallclock secs ( 5.79 usr + 0.01 sys = 5.80 CPU)
the code by
izut took: 3 wallclock secs ( 2.20 usr + 0.01 sys = 2.21 CPU)
And the winner is... izut! :P