Loading, please wait...

A to Z Full Forms and Acronyms

Fibonacci Serious Program using Java

Jul 07, 2018 int, String, DataInputStream, 1380 Views
This Program is used to calculate Fibonacci Serious concept.
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; 
} 
} 
}
A to Z Full Forms and Acronyms

Related Article