Skip to content
Open

LCM.c #116

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions C/LCM.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>

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;
}