This sample program that I wrote in the Java programming language will ask the user to enter two numbers and then our program will compute and determine the least common multiple, or LCM, of the two numbers being provided by our user.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGgThank you very much for your support.

Program Listing


// lcm.java
// Written By: Mr. Jake R. Pomperada, BSCS, MAED-IT
// July 9, 2015   Thursday
// Email Address:  jakerpomperada@gmail.com 
//                 jakerpomperada@yahoo.com

/*
 * 
 * This sample program that I wrote in Java programming language will ask the user to enter two numbers and then our program 
 * will compute and determine the least common multiple or LCM of the two numbers being provided by our user.
 * 
 * http://jakerpomperada.blogspot.com/2015/07/least-common-multiple-lcm-solver-in-java.html
 * 
 * 
 */

import java.util.Scanner;

public class lcm {

    public static void find_lcm(int x, int y)
    {
        int max=0,min=0,z=0,lcm=1;
  if(x>y)
    {
    max=x;
    min=y;
    }
    else
    {
    max=x;
    min=y;
    }

for(int i=1;i<=min;i++)
   {
    z=max*i; 
    if(z%min==0) 
     {
      lcm=z; 
      break; 
     }
    }
    System.out.println();
    System.out.println("The Least Common Multiple (LCM) of "+ x 
                   + " and " + y +  " is = " + lcm + ".");
    }

    
   public static void main(String[] args) {
      Scanner input = new Scanner(System.in);
        
      char ch;
      int first_value=0;
      int second_value=0;
 do {
      System.out.println();
      System.out.print("\t LEAST COMMON MULTIPLE (LCM) SOLVER IN JAVA ");
      System.out.println("\n");
      
      System.out.print("Kindly give the first number  : "); 
      first_value = input.nextInt();
      
      System.out.print("Kindly give the second number : "); 
      second_value = input.nextInt();

      find_lcm(first_value,second_value);
      System.out.print("\nDo you want to continue (Type y or n) : ");
      ch = input.next().charAt(0);                        
     } while (ch == 'Y'|| ch == 'y');  
      System.out.println();
      System.out.print("\t THANK YOU FOR USING THIS PROGRAM");
      System.out.println("\n\n");
   }

}