Monday , December 18 2017
Home / Blue J / Java program to print first 20 fibonacci numbers

Java program to print first 20 fibonacci numbers

Fibonacci Numbers are the numbers in series which follow the concept that every next number is the sum of previous two numbers. But then which were the first two numbers. They are initially taken 0,1 . Series:

0,1,1,2,3,5,8,13,21,34,55,89…..

Also See: c program to print first 20 fibonacci numbers

class prog11
{
void main()
{
int a=0,b=1,c,count=2;
System.out.print(a+",");
System.out.print(b+",");
while(count!=20)  // if you want first 100 fibonacci numbers then change 20 to 100 accordingly 
{
c=a+b;
count++;
System.out.print(c+",");
a=b;
b=c;
}
}
}

 OUTPUT:

Program for fibonacci series

Also See:   Basic concepts of Java: Quick Revision

Check Also

Java program to implement polymorphism

Java program to implement polymorphism: Polymorphism is a technique in java with which you can ...

One comment

  1. Very helpful site

Leave a Reply

Your email address will not be published. Required fields are marked *