Factorial Program in Java – Source Code for Factorial Program

Factorial Program in Java - Source Code for Factorial Program. You can find source code for Factorial Program in this page.

You can find Java source code for Factorial Program in this page. Java Program Factorial Concept.

public class Factorial {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int fact =  fact(5);
System.out.println(“Factorial of 5 : “+fact);
}
public static int fact(int factvalue){
// TODO Auto-generated method stub
int fact ;
if(factvalue == 0)
return 0;
else if(factvalue == 1)
return 1;
else {
fact = factvalue * fact(factvalue-1);
}
return fact;
}
}
Result:
Factorial of 5 : 120