Asah Logika

Postingan kali ini sebagai pembangkit semangat koding Saya yang lama tenggelam.😀

Langsung aja deeh

Mencari Faktorial (Java code)

class Faktorial {
 public static void main(String args[]){
 int i;
 int n = 5;
 int faktorial = 1;

 for(i=1; i<=n; i++){
     faktorial = faktorial*i;
   }
    System.out.println(faktorial);
  }
}

Mencari Bilangan Ganjil

class Ganjil {
 public static void main(String args[]){
 int batas = 13;
 for(int i=0; i<batas; i++){
    if(i % 2 != 0){
       System.out.println(i);
    }
   }
 }
}

Segitiga Bintang

class Bintang {
	public static void main(String args[]){
		/**
		 * 1
		 * 12
		 * 123
		 * 1234
		 * 12345
		 **/

		int batas = 5;

		for(int i=1; i<=batas; i++){
			for(int j=1; j<=i; j++){
				System.out.print("*");
			}
			System.out.println("");
		}
	}
}

Akan terus diupdate !🙂

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