Program FIbonaci

Pada kesempatan kali ini kita akan membahas tentang Program Fibonancy.

Berikut ini adalah cara dan source code nya :

package tugas2;

import javax.swing.JOptionPane;

public class Fibonaci {

public static void main(String[] args) {

String input = JOptionPane.showInputDialog(“Masukkan banyaknya bilangan fibonaci yang diinginkan : (max 20!!!)”);

int i = Integer.parseInt(input);

int a = 1;

int b = 1;

System.out.println(i + “deret fibonaci : “);

for (int x=0; x<=i; x++){

System.out.print(a+” “);

a=a+b;

b=a-b;

}

}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s