Bilangan Fibonacci dengan Java

Berikut adalah Source Code untuk menampilkan bilangan fibonacci dengan java.





/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fibo;

/**
 *
 * @author mwpripanggalih
 */
public class Fibo {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
         int fibo[] = new int[15];

        fibo[0] = 1;
        fibo[1] = 1;

        for (int i = 2; i < fibo.length; i++) {
            fibo[i] = fibo[i - 1] + fibo[i - 2];
        }
        for (int i = 0; i < fibo.length; i++) {
            System.out.println(fibo[i]);
        }
    }
}

Previous
Next Post »