Least Common Multiple (LCM) in Jeliot

Posted by Didi Setyapramana On 6:34 PM 0 komentar

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();

          }

}

Categories:

0 Response for the "Least Common Multiple (LCM) in Jeliot"

Post a Comment