3 ms·
Thankfully, the tenured professor version works in Julia like so: prod(1:63) For bigger numbers, factorial(n) = 1:n .|> BigInt |> prod
by qart 2y ago
Thankfully, the tenured professor version works in Julia like so:
prod(1:63)
For bigger numbers,
factorial(n) = 1:n .|> BigInt |> prod
- soegaard 2y agoIt's not the best algorithm for computing factorials though. A better strategy is to pair small and large factors together in order to avoid bignum computations (or to reduce the size og bignum computations). https://people.eecs.berkeley.edu/~fateman/papers/factorial.pdf https://people.eecs.berkeley.edu/~fateman/papers/factorial.p... Also: It's more fun to use the name `fact` in benchmarks...
- MaxBarraclough 2y agoThe rabbit-hole goes much deeper than that. https://en.wikipedia.org/wiki/Factorial#Computation https://en.wikipedia.org/wiki/Factorial#Computation