SOURCE CODE
import javax.swing.*;
public class DeretFibonaci
{
public static void main(String[] args)
{
int kiri = 0;
int kanan = 1;
int banyak;
int ulang = 0;
String deret = JOptionPane.showInputDialog("Masukkan Jumlah Deret : ");
System.out.println("");
System.out.println("Jumlah Deret : " + deret);
banyak = Integer.parseInt(deret);
System.out.println("");
System.out.println("Deret Fibonaci");
while(ulang < banyak)
{
System.out.print(kanan + " ");
int bantu = kiri + kanan;
kiri = kanan;
kanan = bantu;
ulang++;
}
System.out.println("");
}
}
OUTPUT
Contoh jumlah deret = 20
Terimakasih, semoga bermanfaat
Sumber from my friend https://serverrendi.blogspot.co.id
0 Response to "Java - Menentukan Deret Fibonaci"
Post a Comment