Only 2 real changes here:
...
2) I took out the negative multiplication and swapped to negation, which we always process fast. (-1 * x isn't as efficient as -x, for example.)
But that change makes it a slightly different comparison between different languages.
I purposefully did not try to optimize it for any single language, but rather wanted the same code for each language.
For example, I could have used "i++" instead of "i = i + 1". Some really poor byte-code interpreters (some of mine :( ) do not recognize that these are the same, and generate:
For the former, and:
For the latter. Definitely slower, as it has to go two extra times through the byte code interpreter loop.
I could have used "for" loops, which some languages optimize better than "while" loops.
But since all languages I was testing did not offer those things, I avoided them.
So the goal was not to write the fastest algorithm - but to write to write something to test that could be easily converted to many languages.
But of course, you are free to do what you want :) However, if you're going to compare it with another language processor, it would be more fair to optimize the code for that processor also.
Finally, not trying to cause trouble or anything like that. Just trying to explain the purpose of the code.
It is at best a silly diversion, and like all bench marks, should be taken with a grain of salt, or just completely ignored!