X598: Factorial Example 2

Write a function in Java called factorial(int n) that will take a positive integer as input and returns its factorial as output. Your solution cannot use loops and therefore must be recursive.

Examples:

factorial(1) -> 1
factorial(3) -> 6

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.