Java Program to Find Factorial of a Number
Factorial.txt
File size: 600 Bytes
File content type: text/plain
Category: Practical Files
Subject: Java Programming
/**
*
* @program To print Factorial of a number
* Example: 5! = 1*2*3*4*5
*/
import java.io.*;
public class Factorial {
public static void main(String args[]) throws IOException {
BufferedReader obj = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter number");
int num = Integer.parseInt(obj.readLine());
long factorial = 1;
for(int i = 2 ; i <= num ; i++) {
factorial = factorial*i;
}
System.out.println("Factorial of "+ num +" = "+ factorial);
}
}
Sample Input/Output
Enter number
8
Factorial of 8 = 40320
Factorial Program in Java
Last Updated: July 16, 2022
Related
IPU IBM Notes Unit 3
Category: NotesJuly 17, 2022
FOC Akash Question Paper 2017
Category: Question PapersJuly 16, 2022
IPU BE Notes Unit 2
Category: NotesJuly 16, 2022
FOC File PDF
Category: Practical FilesJuly 16, 2022
Magnetic Circuits - Unit 4 - Handwritten Notes
Category: NotesJuly 16, 2022
EHVACDC Unit 2 Extra High Voltage Testing
Category: NotesJuly 17, 2022
Data Mining Practical File Exp 1-7
Category: Practical FilesJuly 16, 2022
Chemistry Chapter Fuel - Book Pics PDF
Category: NotesJuly 16, 2022
BBA Project Management Notes Unit 3
Category: NotesJuly 17, 2022
Physics First Year Practical File
Category: Practical FilesJuly 16, 2022