/* GCD returns the greatest common divisor of a and b (which must be non-zero).
This algorithm comes from Euclid, Elements, circa 300 BCE, book (chapter)
VII, propositions 1 and 2.
static unsigned GCD(unsigned a, unsigned b)
while (0 < b)
unsigned c = a % b;
a = b;
b = c;
static const unsigned Limit = 20;
unsigned LCM = 1;
/* Update LCM to the least common multiple of the LCM so far and the next
i. The least common multiple is obtained by multiplying the numbers
and removing the duplicated common factors by dividing by the GCD.
for (unsigned i = 1; i <= Limit; ++i)
LCM *= i / GCD(LCM, i);
printf("The least common multiple of numbers from 1 to %u is %u.n",