From 7f8d8cd6ca3f67c9c885859b2161946554eeb17a Mon Sep 17 00:00:00 2001 From: sktagrwl <65661745+sktagrwl@users.noreply.github.com> Date: Mon, 4 Oct 2021 03:21:08 +0530 Subject: [PATCH] Create LCM.java --- LCM.java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 LCM.java diff --git a/LCM.java b/LCM.java new file mode 100644 index 0000000..fe6fb41 --- /dev/null +++ b/LCM.java @@ -0,0 +1,32 @@ +public class LCM { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(); + int b = sc.nextInt(); + int lcm ; + + if (a>b) + { + lcm = a; + } + else + { + lcm = b; + } + while(true) + { + if (lcm%a==0 && lcm%b==0) + { + System.out.println(lcm); + break; + } + ++lcm; + } + + + } + +}