Thursday 21 November 2013

JAVA : Fibonacci Series

Fibnacci Series :

Here is the Java code for the Fibonacci Series :
class Fibonacci
{
 public static void main(String args[])
 {  
  int prev, next, sum, n;
  prev=next=1
  for(n=1;n<=7;n++)
  {
   System.out.println(prev);
   sum=prev+next;
   prev=next;
   next=sum;
  }
 }
}

Output :

1
1
2
3
5
8
13


To know about the Fibonacci Series in detail and also to know the codes of the Fibonacci Series in various other programming languages Click Here

If the above link doesn't work go to this URL :
http://gappcode.blogspot.in/2013/11/fibonacci-series.html

No comments:

Post a Comment