Fibonanci

June 6, 2010 at 12:06 pm Leave a comment

public static void main(String[] args)throws IOException {

//Memanggil Function inputDeret

int JumlahDeret = inputDeret();

//Memanggil Procedure dataFibonanci

dataFibonanci(JumlahDeret);

}

//Funtion

static int inputDeret() throws IOException

{          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

System.out.print(“Masukkan jumlah deret Fibonanci : “);

int xDeret = Integer.parseInt(br.readLine());

return xDeret;

}

//Procedure

static void dataFibonanci(int JumlahDeret2)

{

int data1=0;

int data2=1;

int Fibonanci;

for (int counter=1;counter<=JumlahDeret2;counter++)

{

if (counter==1)

{              System.out.print(data1 + “\t”);

}else if(counter==2)

{              System.out.print(data2 + “\t”);

}else

{              Fibonanci = data1+data2;

data1 = data2;

data2=Fibonanci;

System.out.print(Fibonanci + “\t”);

}}}}

Advertisement

Entry filed under: Uncategorized. Tags: .

Perkalian Array Game Tebak Angka

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


 

June 2010
M T W T F S S
« Jan    
 123456
78910111213
14151617181920
21222324252627
282930  

Pages

Top Posts

  • None

Recent Posts


Blogger Ngalam



helga indra:



Follow

Get every new post delivered to your Inbox.