Write a Java Program to Find Factorial of a Number Using Recursion

Java Program to Find Factorial of a Number Using Recursion

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn Java programming concepts. You can learn Java  language at your own speed and time. One can learn concepts of Java language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Java Program to Find Factorial of a Number Using Recursion
Java Program to Find Factorial of a Number Using Recursion

Write a Java Program to Find Factorial of a Number Using Recursion

PROGRAM: Java Program to Find Factorial of a Number Using Recursion

/*Java Program to Find Factorial of a Number Using Recursion */

public class Factorial {

public static void main(String[] args) {
int num = 6;
long factorial = multiplyNumbers(num);
System.out.println(“Factorial of ” + num + ” = ” + factorial);
}
public static long multiplyNumbers(int num)
{
if (num >= 1)
return num * multiplyNumbers(num – 1);
else
return 1;
}
}

Leave a Reply

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