C Programming Code Examples C > For Loops and While Loops Code Examples LCM using while Loop and if Statement LCM using while Loop and if Statement The LCM of two integers number1 and number2 is the smallest positive integer that is perfectly divisible by both number1 and number2 (without a remainder). For example: the LCM of 72 and 120 is 360. #include <stdio.h> int main() { int number1, number2, minMultiple; printf("Enter two positive integers: "); scanf("%d %d", &number1, &number2); // maximum number between number1 and number2 is stored in minMultiple minMultiple = (number1>number2) ? number1 : number2; // Always true while(1) { if( minMultiple%number1==0 && minMultiple%number2==0 ) { printf("The LCM of %d and %d is %d.", number1, number2,minMultiple); break; } ++minMultiple; } return 0; printf("C Programming Language | Happy Codings :)"); }