From 9dcd5d83c1477b26f63e83654b587a34b4063699 Mon Sep 17 00:00:00 2001 From: Prakharshrivastava2002 <114497274+Prakharshrivastava2002@users.noreply.github.com> Date: Thu, 27 Oct 2022 15:07:02 +0530 Subject: [PATCH] LCM.c --- C/LCM.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 C/LCM.c diff --git a/C/LCM.c b/C/LCM.c new file mode 100644 index 0000000..6045d6a --- /dev/null +++ b/C/LCM.c @@ -0,0 +1,22 @@ +#include + +int main() +{ + int a,b, m; + + printf("Enter two positive integers: "); + scanf("%d %d", &a, &b); + + m = (a > b) ? a : b; + + while (1) + { + if ((m % a == 0) && (m % b == 0)) + { + printf("The LCM of %d and %d is %d.", a, b, m); + break; + } + ++m; + } + return 0; +}