Jumat, 22 Juni 2012

SOURCE CODE FIBONACCI


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

package uts_buroro;

import javax.swing.JOptionPane;

/**
 *
 * @author Masiti
 */
public class fibonacci {
public static void main(String[]args){
    int n=Integer.parseInt(JOptionPane.showInputDialog("input suku ke-n:"));
    int a=0;
    int b=1;
    for(int i=0;i<n;i++){
        a=a+b;
        b=a-b;
        System.out.print(" "+a);
    }
}
}

Tidak ada komentar:

Poskan Komentar