Implement a method factorial
that accepts a single Long
and returns its factorial as a Long
.
You can reject negative arguments and ones greater than 20 by throwing an IllegalArgumentException
.
You should submit a recursive solution. The factorial of 0 is 1, and this represents the base case. The factorial of n is n * the factorial of n - 1, and this represents the recursive step.
You're challenge is to write tests for this problem described above.
Stuck? You may find these lessons helpful: