Least Common Multiple (LCM) in Jeliot

import jeliot.io.*;

public class kpk {

          int a,b,nilai;

          public void masukan() {
          System.out.print("Menghitung KPK");

          nilai=0;
           System.out.print("Masukkan A: "); a=Input.readInt();
          System.out.print("Masukkan B: "); b=Input.readInt();
          for (int z=1; z<=b; z++) {
          nilai=nilai+a;
          if (nilai%b==0) {
          System.out.print("KPK dari ");
          System.out.print(a);
        System.out.print(" dan ");
         System.out.print(b);
          System.out.print(" adalah ");
          System.out.print(nilai);

          }
          }
    }

          public static void main () {
          kpk X = new kpk();
         X.masukan();

          }

}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s