Rabu, 11 Juni 2014

Pemrograman Java : Nilai Fibonacci

Diposting oleh Unknown di 03.18
import javax.swing.*;
public class fibonacci{
public static void main(String[] args) {
        int a=0;
        int b=1;
        int n=Integer.parseInt(JOptionPane.showInputDialog(null,"Masukan Jumlah Pengulangan : ",".:: Angka Fibonacci ::.",JOptionPane.QUESTION_MESSAGE));
        System.out.println("Pengulangan Sebanyak : " +n+" Kali\n");
        for(int i=0; i < n; i++){
            System.out.print(" " + a);
            a=a+b;
            b=a-b;
        }
        System.out.println("\n");
    }
}

0 komentar:

 

Miss Galaxy Yoon Template by Ipietoon Blogger Template | Gift Idea