Write a Java program to find factorial of a given number using recursion.

Below code illustrates about finding a factorial of given number using recursion in Java:

public class FactorialUsingRecursion {
	public static void main(String[] args) {
		int x = 4;
		int result = 0;
		result = factorial(x);
	private static int factorial(int x) {
		if(x > 1) {
			return (x * factorial(x-1));
		return 1;

Author: Mahesh

Technical Lead with 10 plus years of experience in developing web applications using Java/J2EE and web technologies. Strong in design and integration problem solving skills. Ability to learn, unlearn and relearn with strong written and verbal communications.