Skip to content

Instantly share code, notes, and snippets.

@p-pavel
Last active October 18, 2020 20:53
Show Gist options
  • Save p-pavel/d9ae755a2e120216289ac5da39831ea5 to your computer and use it in GitHub Desktop.
Save p-pavel/d9ae755a2e120216289ac5da39831ea5 to your computer and use it in GitHub Desktop.
factorial[n_] :=
Block[{$IterationLimit = \[Infinity]}, factorial[n, 1]];
factorial[0, res_] := res;
factorial[n_, res_] := factorial[n - 1, n res];
Length @ IntegerDigits @ factorial[100000] // AbsoluteTiming (*{0.96279, 456574}*)
Length @ IntegerDigits @ (100000!) // AbsoluteTiming (* {0.050641, 456574} *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment