import
static java.lang.System.out;
import
java.util.Scanner;
class
InputBilfibonaci
{
public static void main(String... args)
{
Scanner s = new Scanner(System.in);
int a = 0; // tipe data integer
int temp = 0;
int b = 0;
int c = 0;
out.println("Masukkan
angka"); //input bilangan
c = s.nextInt();
a = 1;
b = 1;
out.print(a + " ");
if (c == 2)
{
out.print(a);
}
else if (c > 2)
{
out.print(b + " ");
for(int i = 1; i <= c-2; i ++)
{
temp = a + b;
a = b;
b = temp;
out.print(temp + "
");
}
}
}
}
No comments:
Post a Comment