Skip to content

Commit

Permalink
Merge pull request #61 from theroshanantony/patch-3
Browse files Browse the repository at this point in the history
Create lcm of any 2 numbers
  • Loading branch information
AyanSaha25 authored Oct 17, 2020
2 parents dfa740a + 944ee07 commit e107b13
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lcm of any 2 numbers
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
include <stdio.h>
int main() {
int n1, n2, max;
printf("Enter two positive integers: ");
scanf("%d %d", &n1, &n2);

// maximum number between n1 and n2 is stored in min
max = (n1 > n2) ? n1 : n2;

while (1) {
if (max % n1 == 0 && max % n2 == 0) {
printf("The LCM of %d and %d is %d.", n1, n2, max);
break;
}
++max;
}
return 0;
}

0 comments on commit e107b13

Please sign in to comment.