Skip to content

Instantly share code, notes, and snippets.

@diakopter
Created December 26, 2015 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diakopter/62f8f31f8b2e40298896 to your computer and use it in GitHub Desktop.
Save diakopter/62f8f31f8b2e40298896 to your computer and use it in GitHub Desktop.
sub postfix:<!> (Int $n) {
fail "Not a Natural Number in Factorial" if $n < 0;
[*] 2..$n
}
use Test;
isa-ok (-1)!, Failure, "Factorial for -1 fails";
ok 0! == 1, "Factorial for 0";
ok 1! == 1, "Factorial for 1";
ok 5! == 120, "Factorial for a larger integer";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment