Java Program to Find the Factorial of the Number using Recursion #javaprogramming

preview_player
Показать описание
Interview Question : Write a Java Program to Find the Factorial of the number using Recursion.

Factorial of a number N is a product of all natural numbers from 1 to N. In mathematical terms, factorial is denoted by the symbol !. If we say factorial of number 5, then the result would be :

Example 1 : 5! = 5 * 4 * 3 * 2 * 1 = 120
Example 2 : 3! = 3 * 2 * 1 = 6

Factorial Program Steps :
1. Create a method with name fact pass one parameter (n).
2. Condition check if n == 0, return 1 else return n * fact ( n - 1).
3. Create another class with main method.
4. Take input from the user using Scanner object.
5. Create an object of Factorial class and call the fact method.
6. Print the Result.

====================================

Learn Java Programming :

====================================

Learn Data Structures and Algorithms in Java :

====================================
Thank you for Watching :

Happy coding Keep Learning 😊
====================================

subscribe for more videos :

====================================

#java #javaprogramming #factorial #javainterviewquestions #recursion
Рекомендации по теме