Factorial Using Java
This is java code explain a factorial in java using recursion . Recursion is
technique to call a function itself. In this program factorial method calling itself.
public class Facto {
static int factorial(int n){
if(n>=2)
System.out.print( n +"*");
else
System.out.print( +n);
if (n == 1) {
return 1;
}
else
{
return(n * factorial(n-1));
}
}
public static void main(String[] args) {
System.out.println("");
System.out.println("Factorial of 11 is: "+factorial(11));
}
}
Out put of this program after you run ..
11*10*9*8*7*6*5*4*3*2*1Factorial of 11 is: 39916800
Factorial Using Java
Reviewed by Mukesh Jha
on
2:45 AM
Rating:
No comments:
Add your comment