https://issues.dlang.org/show_bug.cgi?id=13371

--- Comment #2 from Don <[email protected]> ---
(In reply to hsteoh from comment #1)
> auto factorial(T)(in T n) {
>     import std.mathspecial : gamma;
>     return gamma(n+1);
> }

Exactly! And I seriously doubt that factorial is commonly used. It's a widely
used _example_, but it's hard to come up with applications for it. Eg even for
calculating permutations and combinations, using factorial is not a good
method.

And for BigInt, iterated multiplication isn't a good way of caclulating
factorials. You need to group multiple factors together, so that the multiplies
are of similar length.

And finally, your code reports factorial(2) == 3, which isn't a good start,

--

Reply via email to