Sunday, April 21, 2013
Iterasi Bilangan Fibonanci
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package new1;
import javax.swing.JOptionPane;
/**
*
* @author surur syifaus
*/
public class fibonanci_iterasi {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int deret=Integer.parseInt(JOptionPane.showInputDialog("Masukkan berapa deret Fibonacci: "));
int a=0;
int b=1;
System.out.print(deret+" deret Fibonacci: " );
for (int i=0;i<deret;i++){
System.out.print(a+" ");
a=a+b;
b=a-b;
}
}
}
Labels:
java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment