Code.GeekInterview.com
 
 

Java Code Base

 
Code Samples Java
 

Fibonacci Series Generator


Code ResourceAuthor: ashish.cns  

Difficulty Level: Beginner

Published: 6th Jan 2010   Read: 6348 times  

Filed in: Java
Add Comment


 

 

Sponsored Links


 

 

This code helps you to get an idea what fibonacci series is and how it can be obtained through a simple java program.

 


Sample Code
  1. import java.io.DataInputStream; //imports all of the input stream class from the io classes
  2. class fibonacci
  3. {
  4.       public static void main(String args[])
  5.       {
  6.       DataInputStream input=new DataInputStream(System.in);
  7.       float a=-1,b=1,c;
  8.       int n,i=0;
  9.       System.out.println("enter the no. of terms u want in d series...");
  10.       n=Integer.parseInt(input.readLine());
  11.       while(i<n)
  12.       {
  13.        c=a+b;
  14.        System.out.println(c);
  15.        a=b;
  16.        b=c;
  17.        i++;
  18.       }
  19.       System.out.println("bye bye...");
  20.       }
  21. }  
  22.  
Copyright GeekInterview.com


Next Article: Code Executing Commands


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Popular Coders

# Coder NameHits
1. srinivasaraobora130745
2. iamdvr97694
3. venki_madesh35134
4. Raju18488
5. parmod kumar duhan15756
6. Kiran.jakkaraju14058
7. chowsys7457
8. Venkateswara Rao6477
9. ashish.cns6349
10. Vamshidhar Matam5428

Active Coders

Refined Tags