- 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 print the factorial of the given number
Factorial of a positive integer n is the product of all values from n to 1. For example, the factorial of 3 is (3 * 2 * 1 = 6).
Algorithm
1. Take integer variable A 2. Assign a value to the variable 3. From value, A up to 1 multiply each digit and store 4. The final stored value is factorial of A
Example
import java.util.Scanner; public class Factorial { public static void main(String args[]){ int i, factorial=1, number; System.out.println("Enter the number to which you need to find the factorial:"); Scanner sc = new Scanner(System.in); number = sc.nextInt(); for(i = 1; i<=number; i++) { factorial = factorial * i; } System.out.println("Factorial of the given number is:: "+factorial); } }
Output
Enter the number to which you need to find the factorial: 25 Factorial of the given number is:: 2076180480
- Related Articles
- Java program to find the factorial of a given number using recursion
- Java program to print the reverse of the given number
- Java program to calculate the factorial of a given number using while loop
- Java Program to Find Factorial of a number
- Java program to print Fibonacci series of a given number.
- Java program to print the fibonacci series of a given number using while loop
- Write a Golang program to find the factorial of a given number (Using Recursion)
- Java Program to Find Factorial of a Number Using Recursion
- 8085 program to find the factorial of a number
- 8086 program to find the factorial of a number
- Golang Program to Print the Multiplication Table of a Given Number
- Java Program to Count trailing zeroes in factorial of a number
- Haskell Program To Find The Factorial Of A Positive Number
- Python Program to find the factorial of a number without recursion
- Java program to print whether the given string is a palindrome

Advertisements