Java Program to Find Factorial of a Number Using Recursion - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
Java Program to Find Factorial of a Number Using Recursion

Java Program to Find Factorial of a Number Using Recursion

Java Program to Find Factorial of a Number Using Recursion

Example: 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;
    }
}
When you run the program, the output will be:
Factorial of 6 = 720

About Mariano

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.