Introduction
In this blog, I will explain about the Factorial program, using Java I/O stream. It is very simple in Java programming. The output will be displayed in the Run module.
Software Requirement
JDK1.3.
Simple program
- import java.io.*;
- class da {
- public static void main(String arg[]) throws IOException {
- DataInputStream d = new DataInputStream(System.in);
- int i, n, f;
- String s;
- f = 1;
- System.out.print("enter the number : ");
- s = d.readLine();
- n = Integer.parseInt(s);
- for (i = 1; i <= n; i++) {
- f = f * i;
- }
- System.out.println("\n" + "factorial of given number " + n + " is : " + f);
- }
- }
In this blog, I will explain about the Factorial program, using Java I/O stream. The output will be displayed in the Run module.