import java.util.Scanner;
public class Fibonacci
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int n;
System.out.print("Masukan Nilai n = ");
n=in.nextInt();
System.out.println("Jumlah Nilai Fibonacci = " +Fibonaci(n));
}
static int Fibonaci(int n)
{
if ((n == 1)||(n==2))
return (1);
else
return (Fibonaci(n-1)+Fibonaci(n-2));
}
public class Fibonacci
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int n;
System.out.print("Masukan Nilai n = ");
n=in.nextInt();
System.out.println("Jumlah Nilai Fibonacci = " +Fibonaci(n));
}
static int Fibonaci(int n)
{
if ((n == 1)||(n==2))
return (1);
else
return (Fibonaci(n-1)+Fibonaci(n-2));
}
}
0 komentar:
Posting Komentar