Factorial program in Java


public class factorial
{
static int fact(int n)
{
if(n==0 || n==1)
return 1;
else
return n*fact(n-1);
}
public static void main(String [] args)
{
System.out.println("Factorial(4)="+fact(4));
}
}

Comments

Popular posts from this blog

GL_QUAD_STRIP Example In OpenGl

GL_POLYGON Example In OpenGl