- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Java program to find the factorial of a given number using recursion

Recursion is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the function.

Following is an example to find the factorial of a given number using a recursive function.

import java.util.Scanner; public class ab21_FactorialUsingRecursion { public static long factorial(int i) { if(i <= 1) { return 1; } return i * factorial(i - 1); } public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter the number to which you need to find the factorial"); int i = sc.nextInt(); System.out.println("Factorial of the given number is ::"+ factorial(i)); } }

## Output

Enter the number to which you need to find the factorial 12 Factorial of the given number is ::479001600

- Related Articles
- Java Program to Find Factorial of a Number Using Recursion
- Write a Golang program to find the factorial of a given number (Using Recursion)
- C++ Program to Find Factorial of a Number using Recursion
- C++ program to Calculate Factorial of a Number Using Recursion
- Python Program to find the factorial of a number without recursion
- Factorial program in Java using recursion.
- Factorial program in Java without using recursion.
- Java program to calculate the power of a Given number using recursion
- Java program to calculate the GCD of a given number using recursion
- How to Find Factorial of Number Using Recursion in Python?
- Java program to calculate the factorial of a given number using while loop
- Swift program to find the reverse of a given number using recursion
- Java Program to Find Factorial of a number
- Java program to print the factorial of the given number
- Java Program to Find Sum of Digits of a Number using Recursion

Advertisements