// Function to find the Least Common Multiple (LCM) of two numbers
function LMC(a: number, b: number): number {
// Start with the greater of the two numbers
let lmc: number = (a > b) ? a : b;
// Loop indefinitely until we find the LCM
while (true) {
// If `lmc` is divisible by both numbers, it is the LCM
if (lmc % a == 0 && lmc % b == 0) {
return lmc; // Return the LCM
}
lmc++; // Increment and check the next number
}
}
// Variable to store the LCM of numbers from 1 to 10
let result: number = 1;
// Iterate through numbers 1 to 10
for (let i: number = 1; i <= 10; i++) {
result = LMC(result, i); // Update `result` with LCM of current range
}
// Output the final LCM of numbers from 1 to 10
console.log(result);
/*
run:
2520
*/