Introduction
In this blog, I will explain about a Fibonacci series 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 fib {
- public static void main(String arg[]) throws IOException {
- int f1 = -1, f2 = 1, f3, i, n;
- String s = new String();
- DataInputStream dr = new DataInputStream(System.in);
- System.out.println("emter the number : ");
- s = dr.readLine();
- n = Integer.parseInt(s);
- for (i = 0; i < n; i++) {
- f3 = f1 + f2;
- System.out.println(f3);
- f1 = f2;
- f2 = f3;
- }
- }
- }
In this blog, I explained about a Fibonacci series program, using Java I/O Stream. The output will be displayed in the Run module.