Bilangan Fibonacci Pada Java

on 15 October 2012

Fibonacci
Fibonacci

Tanpa basa basi langsung copas aja kode di bawah buat bahan pembelajaran .^^


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

package modul1;

/**
 *
 * @author Gita
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
     int input = 8;
     int bil1 = 0;
     int bil2 = 1;
     int temp = 0;

       for(int i=1;i<=input;i++){
        temp=bil1+bil2;
        System.out.print(" "+bil1);
        bil1=bil2;
        bil2=temp;
       }
    }

}
Ranking: 5

{ 0 komentar... read them below or add one }

Post a Comment

Blogger yang baik, selalu meninggalkan komentar setelah membaca .
^-^

Related Posts Plugin for WordPress, Blogger...

Berlangganan via email :


.
 
© Agit Share | Blognya Si Agit | All Rights Reserved
D.I.Y Themes ByBelajar SEO