You are hereArray / Recursive function in JSP
Recursive function in JSP
This snippet demonstrates how to constructs a function and how to implement factorial function in recursive mode.
<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>
- hendro.subagyo's blog
- Login or register to post comments
Tags
Programmer, lecturer and researcher. Kota Bekasi's citizen, but spend time mostly in Jakarta. Maried with 4 children.