Ads

# Java Factorial Program

I want to create a factorial program in Java. Please help me.

View Answers June 12, 2012 at 5:54 PM

```import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Factorial {
public static void main(String args[]) throws IOException {
System.out.println("Please Input Any Number");
int num = 0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String data = (String) br.readLine();

num = Integer.parseInt(data);

int result = num;
for (int i = 1; i < num; i++) {
result *= i;
//result = result * i;
}
System.out.println(result);
}

}
```

Output

```Input Any Number
5
120
```

Description:- In the above example find out the factorial of a number. Here, we have used BufferedReader class to input a number to find its factorial. The method readLine() of this class reads the value. As this method returns string type so we have converted it to integer. Then using the loop, we got the factorial of the input number.

Ads

Related Tutorials/Questions & Answers:
program on factorial of a given number in java
program on factorial of a given number in java  please tell me, how to write program on factorial of a given number in java
program on factorial of a given number in java
program on factorial of a given number in java  please tell me, how to write program on factorial of a given number in java
Advertisements
Factorial Program in Java
Factorial program in Java helps programmer to write factors of any given... exception". Example of Factorial program in Java: import java.io.*; class... execution of the program. BufferReader is defined under the Java I/O package
Write a program to calculate factorial of any given number
Factorial Examples - Java Factorial Example to calculate factorial of any... program to calculate factorial of any given number. First of all define a class... in java. Here is the code of program: import
java program code
java program code  can any one write a program (class) which will have two methods Fibonacci and Factorial, which will be a void and a return respectively. i will be glad if it can have a good display results
Write a program to find a factorial in any given number
Write a program to find a factorial in any given number This programming tutorial will teach you how to write a factorial of any given number... that is equal to 24, and factorial of  0! is 0 always.Example : A program to find
java program for
java program for   java program for printing documents,images and cards
Write a program in java...
to enter an integer number. Write a program in java to find the factorial...Write a program in java...  Hi, friends Please, can you help me? Q1: Write a program in java to simulate a calculator. Your program should take two
a Java program
a Java program    Write a Java program to print even numbers from 2 to 1024? Write a Java program to print ? My Name is Mirza? 100 times? Write a Java program to print Fibonacci Series? Write a Java program to reverse a number
java program
java program  how to write an addition program in java without using arithematic operator
java program
java program  write java program for constructor,overriding,overriding,exception handling
java program
java program  write a java program to display array list and calculate the average of given array
java program
java program  write a java program to display array list and calculate the average of given array
Java Program
Java Program  java program to insert row in excel sheet after identifying an object
java program
java program  java program to implement the reflection of a particular class details like constructor,methods and fields with its modifiers
java program
java program  Write a java program to do matrix addition operation On two given matrices
java program
java program  Write a java program to find the number of Positive numbers in m* n matrix
java program
java program  Write a program to create an applet and display The message "welcome to java
java program
java program  hi friends how to make a java program for getting non prime odd numbers in a given series
ModuleNotFoundError: No module named 'factorial'
ModuleNotFoundError: No module named 'factorial'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'factorial' How to remove the ModuleNotFoundError: No module named '
java program
java program  Write a program to demonstrate the concept of various possible exceptions arising in a Java Program and the ways to handle them.  ... in Java
java program
java program  write a program to print 1234 567 89 10
java program
java program  write a java program to compute area of a circle.square,rectangle.triangle,volume of a sphere ,cylinder and perimeter of cube using method over riding
java program
java program  write a java program to compute area of a circle.square,rectangle.triangle,volume of a sphere ,cylinder and perimeter of cube using method over riding
find the factorial
find the factorial  how to find the factorial through the while loop...) { int value = 5, factorial = 1, temp = value; while (temp > 0) { factorial *= temp; temp
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
java program
java program  i want a applet program that accepts two input strings using tag and concatenate the strings and display it in status window. please give mi he code for this in core java
java program
java program  write a java program to read a file which hold email address validate email address tohave formate @.* and replace all .com email address
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
Java Program
Java Program  I want to Write a program in JAVA to display to create a class called MATRIX using a two-dimensional array of integers. Perform the addition and subtraction of two matrices. Help me

Ads