Complete the recursive factorial(n) method. n! = n × (n-1) × ... × 1, and by definition 0! = 1. This is enrichment beyond the core syllabus, but recursion does appear in harder IEB papers.
Input / Output
Input: a non-negative integer n. Output: n! (n factorial).
Examples
Input
5
Expected Output
120
Input
0
Expected Output
1
+ 2 hidden tests checked on Submit.
Main.java is the entry point. Add extra classes for OOP exercises — they compile together.
Run your code to see test results here.