Tugas Mas Haritz

Tugas Algoritma Pemrograman

 

  1. 1.       Menampilkan bilangan ganjil antara 1-50 dengan menggunakan bahasa pemrograman.

 

public class tugas {

public static void main (String[]args){

for(int x =1 ; x <=50 ; x+=2){

System.out.println (x);

}

}

}

  1. 2.      Menampilkan bilangan Fibonacci dengan menggunakan bahasa pemrograman.

 

public class fibo{
public static void main(String [] args){
int n=1;
int total=0;
int a=0;

System.out.println(total);
System.out.println(n);
for(int i=0;i<20;i++){
total=a+n;
System.out.println(total);
a=n;
n=total;

}

}

}

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 )

Google+ photo

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

Connecting to %s