The Factorial challenge is one of the canonical challenges on our site. Just like "Hello World", "Add two numbers", "Primality test", and "Fibonacci", it attracts answers written in newly created languages every now and then. But still, it has a set of old-fashioned requirements on the domain, performance, and banning built-ins:
- Does not use any built-in libraries that can calculate the factorial (this includes any form of eval)
- Can calculate factorials for numbers up to 125
- Can calculate the factorial for the number 0 (equal to 1)
- Completes in under a minute for numbers up to 125
The third point is perfectly valid requirement because it is part of the definition of factorial, but other three have problems.
125!
is a 210-digit integer, which cannot be accurately represented in machine precision (neither int64 nor float64), so it obviously requires infinite-precision integers (either built-in or rolling one's own), which unnecessarily penalizes the languages without built-in support. Some of the pre-existing answers may already fail this requirement.
The performance requirement is even worse. It entirely bans the Turing tarpits where the only operation on a number is increment, since it would need to run the increment command at least 125!
times to get the answer no matter what. If you insist to implement multi-digit system to enhance the performance, it doesn't solve the problem; it just changes the problem to the one in the previous paragraph.
Note that many existing answers already violate some of the rules, mostly by using machine-size int/float number type or by using Brainfuck and ignoring performance.
I believe that, under the current site culture, we consider a solution valid if
- it solves the task at least theoretically in finite time, given enough time and memory;
- if it uses limited precision built-in number type, the solution would work for higher numbers if the number type were infinite-precision.
And I think, if we agree that it is one of the canonical challenges, we should encourage participation in more languages by lifting the restrictions.
So the question is (as in the title): Should we remove unnecessary restrictions on the factorial challenge?