Factorial Program Using Java With I/O Streams

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
  1. import java.io.*;  
  2. class da {  
  3.  public static void main(String arg[]) throws IOException {  
  4.   DataInputStream d = new DataInputStream(System.in);  
  5.   int i, n, f;  
  6.   String s;  
  7.   f = 1;  
  8.   System.out.print("enter the number : ");  
  9.   s = d.readLine();  
  10.   n = Integer.parseInt(s);  
  11.   for (i = 1; i <= n; i++) {  
  12.    f = f * i;  
  13.   }  
  14.   System.out.println("\n" + "factorial of given number " + n + " is : " + f);  
  15.  }  
  16. }  
Explanation
 
In this blog, I will explain about the Factorial program, using Java I/O stream. The output will be displayed in the Run module.

Output
 
l