Selamat Datang Di Blogg Saya

Rabu, 11 April 2012

program fibonanci Java



Program Jeliot :
import jeliot.io.*;
public class MyClass {
public static void main() {
fibonacci x = new fibonacci();
x.masukan();
x.proses();
x.keluaran();}}
class fibonacci{
void masukan(){
System.out.print("Deret Fibonacci");
System.out.print("\nMasukkan batas deret fibonacci: ");
n = Input.readInt();}
void proses(){
for (i =0;i<n;i++){
if (i<2)
a[i] =i;
else
a[i] =a[i-2]+a[i-1];}}
void keluaran(){
for(i =0;i<n;i++){
System.out.print(a[i]);
System.out.print(" ");}}
private int n;
private int i;
private int[] a = new int[50];

0 comments:

Posting Komentar