Skip to content
cwholt edited this page Jan 23, 2012 · 13 revisions

Write a program that computes the factorial of a given integer in the language of your choosing. Fastest implementation wins. I'll time each entry on my machine.

Your program should accept the integer as its sole argument.

For any interested ActionScripters, you can just submit the factorial function--I'll create a test harness and compile it with redtamarin.

Results

1000 iterations evaluating 12!

It's worth noting that since each call to the program entails potentially loading an environment, this test reflects the quality of the program as a utility, and not the quickness of the function implementation itself.

  1. Chul (C) -- 3.711580
  2. Mark (C) -- 3.819705
  3. Andres (C++) -- 3.826079
  4. Drew (Haskell) -- 4.567761
  5. cwh (Ruby) -- 5.198536
  6. Andres (AS3) -- 16.034052
  7. Will (AS3) -- 16.701006
  8. Jason (Erlang) -- 127.315488
  9. Ferose (Java) -- 190.650340

1000 iterations evaluating 120!

Chul, Mark, Will and Andres' programs could not correctly evaluate 120! and were therefore disqualified.

  1. Drew (Haskell) -- 4.472966
  2. cwh (Ruby) -- 5.144360
  3. Jason (Erlang) -- 127.184300
  4. Ferose (Java) -- 191.249031

Evaluating 100,000!

Jason's program did not correctly evaluate 100,000! and was therefore disqualified.

  1. Drew (Haskell) -- 3.314
  2. Ferose (Java) -- 36.249
  3. cwh (Ruby) -- 46.448

Clone this wiki locally