Posted by Materi Teknik Informatika • Informasi Teknologi Informasi • Digital Marketing on 9/20/2014
import java.util.Scanner;
public class Fibonacci_Rekursif_Tian_Chan {
public Fibonacci_Rekursif_Tian_Chan() {
}
public static void main(String [] args){
int n, tian, i;
Scanner input = new Scanner(System.in);
System.out.print("Berikan Batas Deret Fibbonaci = ");
n = input.nextInt();
for(i=0; i<=n; i++)
{
tian = countFibbo(i);
System.out.print(tian+" ");
}
}
//Fungsi Rekusif nya
public static int countFibbo(int n){
int chan;
if(n==0)
return 0;
if(n==1)
return(1);
else
chan = countFibbo(n-1) + countFibbo(n-2);
return chan;
}
}
Berikut hasil output Program Mencari Deret Bilangan Fibonacci Menggunakan Rekursif yang dihasilkan.