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

Check Also

Program to check Upper Triangular matrix

What is Upper Triangular Matrix?  An upper triangular matrix is a square matrix in which ...

One comment

  1. Very helpful site

Leave a Reply

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

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.