tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Java > Core > Special Numbers > Febonic Series

Febonic Series 

Febonic Series

File Name  :  
com/bethecoder/tutorials/core/special_numbers/FebonicSeries.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.core.special_numbers;

public class FebonicSeries {

  /**
   @param args
   */
  public static void main(String[] args) {
    printFebonicSeries(0112);
    printFebonicSeries(2412);
    printFebonicSeries(1512);
  }
  
  public static void printFebonicSeries(int first, int second, int required) {

    show(first); show(second);
    
    //0 1 1 2 3 5 8 13 21 34
    for (int i = ; i < required ; i ++ ) {
      show(first + second);
      second = first + (first = second);
    }
    
    System.out.println();
  }
  
  private static void show(int num) {
    System.out.print(num + "  ");
  }

}
   

It gives the following output,
0  1  1  2  3  5  8  13  21  34  55  89  144  233  
2  4  6  10  16  26  42  68  110  178  288  466  754  1220  
1  5  6  11  17  28  45  73  118  191  309  500  809  1309  



 
  


  
bl  br