Guest User

Untitled

a guest
Nov 22nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int n1, n2, minMultiple;
  5. printf("Enter two positive integers: ");
  6. scanf("%d %d", &n1, &n2);
  7.  
  8. // maximum number between n1 and n2 is stored in minMultiple
  9. minMultiple = (n1>n2) ? n1 : n2;
  10.  
  11. // Always true
  12. while(1)
  13. {
  14. if( minMultiple%n1==0 && minMultiple%n2==0 )
  15. {
  16. printf("The LCM of %d and %d is %d.", n1, n2,minMultiple);
  17. break;
  18. }
  19. ++minMultiple;
  20. }
  21. return 0;
  22. }
Add Comment
Please, Sign In to add comment