Email: Password:       Forgot Password 
    .netCodeSG
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.
 
TECHNOLOGIES:
 

Fibonacci series

Article:
Viewed:  1050 
Posted On:  23/07/2013 12:07:24 
In this article I am going to explain how we can print the fibonacci series....till 50 terms in java  

 

In this article we are going to learn how to make Fibonacci series in JAVA step by step...

Below is my code: 

class fibonacci
{
public static void main(String s[])
{
int a,b=0,c=1,d;
System.out.print(""+b);
System.out.print(","+c);
for(a=1;a<=50;a++)
{
d=b+c;
b=c;
c=d;
System.out.print(","+d);
}
}


 Step 1:  
After writing this in notepad save the file with the name followed by (.java) for eg.i saved it with fibonacci.java

Step 2 : 
Open command prompt.

Step 3 :
Write javac fibonacci.java - Press Enter for compilation.

Step 4 :
 
Write java fibonacci for execution


Now Output:

JavaFirstPrograme.png

Image 1.

  Comment:
         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us