Using Recursion
<HTML> <HEAD> <TITLE>Using Recursion</TITLE> </HEAD> <BODY> <H1>Using Recursion</H1> <%! int factorial(int n) { if (n == 1) { return n; } else { return n * factorial(n - 1); } } %> <% out.println("The factorial of 6 is " + factorial(6)); %> </BODY> </HTML>