Factorial or Find factorial value in java

Find factorial using java program. Below demo java program can be use to find factorial value of any input parameter

public class Factorial{

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println("Factorial value: " + fact(7));

	}

	static int fact(int n) {
		int result;

		if (n == 1)
			return 1;

		result = fact(n - 1) * n;
		return result;
	}

}

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *