Fibonacci series in java

 Fibonacci series in java

public class Fibonacci
{
   public static void main(String args[]){
    int f1=0,f2=1,f3,i=3,n=10;
    System.out.print(f1+" "+f2);
    while(i<=n){
    f3=f1+f2;
    System.out.print(" "+f3);
    f1=f2;
    f2=f3;
    i++;
    }
    }
}

Output
0 1 1 2 3 5 8 13 21 34

Comments

Popular posts from this blog

Make a GST Calculator using HTML and JavaScript

How to make simple bill maker by using python tkinter

Write a program to find the sum of 1/2+4/3+5/6+8/7+9/10 using loop in java