Skip to content
This repository has been archived by the owner on Sep 27, 2020. It is now read-only.

Commit

Permalink
Added a program for LCM of 2 numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
JeeBoomBoi committed Oct 9, 2019
1 parent e1e6017 commit e411d58
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions C/LCMoftwonumbers.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <stdio.h>
int main()
{
int n1, n2, minMultiple;
printf("Enter two positive integers: ");
scanf("%d %d", &n1, &n2);
minMultiple = (n1>n2) ? n1 : n2;
while(1)
{
if( minMultiple%n1==0 && minMultiple%n2==0 )
{
printf("The LCM of %d and %d is %d.", n1, n2,minMultiple);
break;
}
++minMultiple;
}
return 0;
}

0 comments on commit e411d58

Please sign in to comment.