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

Calculate Compound Interest in JavaScript

How to make simple bill maker by using python tkinter

Admin Login Page Using HTML and CSS